Always register Google OAuth2 strategy in test env so route helper is available

pull/687/head
Wabo 3 weeks ago
parent f848f073aa
commit 78264a3584

@ -338,12 +338,15 @@ Devise.setup do |config|
# when this initializer runs. Read ENV directly here so the omniauth strategy # when this initializer runs. Read ENV directly here so the omniauth strategy
# can be registered at boot. Controllers/models access the same values via # can be registered at boot. Controllers/models access the same values via
# Wabosign::GOOGLE_* once Rails is fully initialized. # Wabosign::GOOGLE_* once Rails is fully initialized.
#
# Always register in test so route helpers are available; in other
# environments only register when credentials are configured.
google_client_id = ENV.fetch('GOOGLE_CLIENT_ID', nil) google_client_id = ENV.fetch('GOOGLE_CLIENT_ID', nil)
google_client_secret = ENV.fetch('GOOGLE_CLIENT_SECRET', nil) google_client_secret = ENV.fetch('GOOGLE_CLIENT_SECRET', nil)
if google_client_id.present? && google_client_secret.present? if Rails.env.test? || (google_client_id.present? && google_client_secret.present?)
config.omniauth :google_oauth2, config.omniauth :google_oauth2,
google_client_id, google_client_id || 'test-client-id',
google_client_secret, google_client_secret || 'test-client-secret',
{ {
scope: 'email,profile', scope: 'email,profile',
prompt: 'select_account', prompt: 'select_account',

Loading…
Cancel
Save