Merge pull request #10289 from colinux/fix-preferred-domain
Tech: n'assigne pas le domaine préféré à l'inscription/connexion si la feature n'est pas activée
This commit is contained in:
commit
6e9bae4f0c
5 changed files with 20 additions and 12 deletions
|
@ -40,7 +40,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
end
|
||||
|
||||
super do
|
||||
resource.update_preferred_domain(Current.host) if resource.valid?
|
||||
resource.update_preferred_domain(Current.host) if resource.valid? && helpers.switch_domain_enabled?(request)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class Users::SessionsController < Devise::SessionsController
|
|||
|
||||
if user&.valid_password?(params[:user][:password])
|
||||
user.update(loged_in_with_france_connect: nil)
|
||||
user.update_preferred_domain(Current.host)
|
||||
user.update_preferred_domain(Current.host) if helpers.switch_domain_enabled?(request)
|
||||
end
|
||||
|
||||
super
|
||||
|
|
|
@ -7,14 +7,12 @@ module DomainMigratableConcern
|
|||
validates :preferred_domain, inclusion: { in: User.preferred_domains.keys, allow_nil: true }
|
||||
|
||||
def update_preferred_domain(host)
|
||||
# DIRTY FIX
|
||||
#
|
||||
# case host
|
||||
# when ApplicationHelper::APP_HOST
|
||||
# preferred_domain_demarches_gouv_fr!
|
||||
# when ApplicationHelper::APP_HOST_LEGACY
|
||||
# preferred_domain_demarches_simplifiees_fr!
|
||||
# end
|
||||
case host
|
||||
when ApplicationHelper::APP_HOST
|
||||
preferred_domain_demarches_gouv_fr!
|
||||
when ApplicationHelper::APP_HOST_LEGACY
|
||||
preferred_domain_demarches_simplifiees_fr!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,6 +44,11 @@ describe Users::RegistrationsController, type: :controller do
|
|||
|
||||
before do
|
||||
allow(Current).to receive(:host).and_return(ENV.fetch("APP_HOST"))
|
||||
Flipper.enable(:switch_domain)
|
||||
end
|
||||
|
||||
after do
|
||||
Flipper.disable(:switch_domain)
|
||||
end
|
||||
|
||||
context 'when user is correct' do
|
||||
|
@ -54,7 +59,7 @@ describe Users::RegistrationsController, type: :controller do
|
|||
|
||||
subject
|
||||
|
||||
# expect(User.last.preferred_domain_demarches_gouv_fr?).to be_truthy
|
||||
expect(User.last.preferred_domain_demarches_gouv_fr?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -69,12 +69,17 @@ describe Users::SessionsController, type: :controller do
|
|||
context 'when user has not yet a preferred domain' do
|
||||
before do
|
||||
allow(Current).to receive(:host).and_return(ENV.fetch("APP_HOST"))
|
||||
Flipper.enable(:switch_domain)
|
||||
end
|
||||
|
||||
after do
|
||||
Flipper.disable(:switch_domain)
|
||||
end
|
||||
|
||||
it 'update preferred domain' do
|
||||
subject
|
||||
|
||||
# expect(user.reload.preferred_domain_demarches_gouv_fr?).to be_truthy
|
||||
expect(user.reload.preferred_domain_demarches_gouv_fr?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue