use email_merge_token in mail_merge_with_existing_account route

This commit is contained in:
simon lehericey 2024-01-11 10:40:44 +01:00
parent 90f145e17a
commit fca28a3ebd
3 changed files with 11 additions and 7 deletions

View file

@ -141,6 +141,10 @@ class FranceConnect::ParticulierController < ApplicationController
params[:merge_token]
end
def email_merge_token_params
params[:email_merge_token]
end
def password_params
params[:password]
end

View file

@ -177,7 +177,7 @@ Rails.application.routes.draw do
get 'particulier' => 'particulier#login'
get 'particulier/callback' => 'particulier#callback'
get 'particulier/merge/:merge_token' => 'particulier#merge', as: :particulier_merge
get 'particulier/mail_merge_with_existing_account/:merge_token' => 'particulier#mail_merge_with_existing_account', as: :particulier_mail_merge_with_existing_account
get 'particulier/mail_merge_with_existing_account/:email_merge_token' => 'particulier#mail_merge_with_existing_account', as: :particulier_mail_merge_with_existing_account
post 'particulier/resend_and_renew_merge_confirmation' => 'particulier#resend_and_renew_merge_confirmation', as: :particulier_resend_and_renew_merge_confirmation
post 'particulier/merge_with_existing_account' => 'particulier#merge_with_existing_account'
post 'particulier/merge_with_new_account' => 'particulier#merge_with_new_account'

View file

@ -268,10 +268,10 @@ describe FranceConnect::ParticulierController, type: :controller do
describe '#mail_merge_with_existing_account' do
let(:fci) { FranceConnectInformation.create!(user_info) }
let!(:merge_token) { fci.create_merge_token! }
let!(:email_merge_token) { fci.create_email_merge_token! }
context 'when the merge_token is ok and the user is found' do
subject { post :mail_merge_with_existing_account, params: { merge_token: fci.merge_token } }
subject { post :mail_merge_with_existing_account, params: { email_merge_token: } }
let!(:user) { create(:user, email: email, password: 'abcdefgh') }
@ -298,8 +298,8 @@ describe FranceConnect::ParticulierController, type: :controller do
end
end
context 'when the merge_token is not ok' do
subject { post :mail_merge_with_existing_account, params: { merge_token: 'ko' } }
context 'when the email_merge_token is not ok' do
subject { post :mail_merge_with_existing_account, params: { email_merge_token: 'ko' } }
let!(:user) { create(:user, email: email) }
@ -308,7 +308,7 @@ describe FranceConnect::ParticulierController, type: :controller do
fci.reload
expect(fci.user).to be_nil
expect(fci.merge_token).not_to be_nil
expect(fci.email_merge_token).not_to be_nil
expect(controller.current_user).to be_nil
expect(response).to redirect_to(root_path)
end
@ -359,7 +359,7 @@ describe FranceConnect::ParticulierController, type: :controller do
subject
fci.reload
get :mail_merge_with_existing_account, params: { merge_token: fci.merge_token }
get :mail_merge_with_existing_account, params: { email_merge_token: fci.merge_token }
expect(controller).not_to have_received(:sign_in)
expect(flash[:alert]).to be_present
end