From fca28a3ebdbd72f3b7f0033e67fdcbc04b638135 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 11 Jan 2024 10:40:44 +0100 Subject: [PATCH] use email_merge_token in mail_merge_with_existing_account route --- .../france_connect/particulier_controller.rb | 4 ++++ config/routes.rb | 2 +- .../france_connect/particulier_controller_spec.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index f4c784941..ffe24c883 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index de03dee2f..fce4e44a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/spec/controllers/france_connect/particulier_controller_spec.rb b/spec/controllers/france_connect/particulier_controller_spec.rb index 81fc1a460..d09d24ac9 100644 --- a/spec/controllers/france_connect/particulier_controller_spec.rb +++ b/spec/controllers/france_connect/particulier_controller_spec.rb @@ -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