diff --git a/app/controllers/agent_connect/agent_controller.rb b/app/controllers/agent_connect/agent_controller.rb index 93be41843..973f67699 100644 --- a/app/controllers/agent_connect/agent_controller.rb +++ b/app/controllers/agent_connect/agent_controller.rb @@ -50,7 +50,7 @@ class AgentConnect::AgentController < ApplicationController instructeur.user.update!(email_verified_at: Time.zone.now) aci = AgentConnectInformation.find_or_initialize_by(instructeur:, sub: user_info['sub']) - aci.update(user_info.slice('given_name', 'usual_name', 'email', 'sub', 'siret', 'organizational_unit', 'belonging_population', 'phone')) + aci.update(user_info.slice('given_name', 'usual_name', 'email', 'sub', 'siret', 'organizational_unit', 'belonging_population', 'phone').merge(amr:)) sign_in(:user, instructeur.user) diff --git a/spec/controllers/agent_connect/agent_controller_spec.rb b/spec/controllers/agent_connect/agent_controller_spec.rb index 723d68320..45c614f88 100644 --- a/spec/controllers/agent_connect/agent_controller_spec.rb +++ b/spec/controllers/agent_connect/agent_controller_spec.rb @@ -67,6 +67,7 @@ describe AgentConnect::AgentController, type: :controller do expect { subject }.to change { User.count }.by(1).and change { Instructeur.count }.by(1) expect(controller).to have_received(:sign_in) + expect(User.last.instructeur.agent_connect_information.last.amr).to eq(amr) end end end