use email_merge_token in mail_merge_with_existing_account route
This commit is contained in:
parent
90f145e17a
commit
fca28a3ebd
3 changed files with 11 additions and 7 deletions
|
@ -141,6 +141,10 @@ class FranceConnect::ParticulierController < ApplicationController
|
||||||
params[:merge_token]
|
params[:merge_token]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def email_merge_token_params
|
||||||
|
params[:email_merge_token]
|
||||||
|
end
|
||||||
|
|
||||||
def password_params
|
def password_params
|
||||||
params[:password]
|
params[:password]
|
||||||
end
|
end
|
||||||
|
|
|
@ -177,7 +177,7 @@ Rails.application.routes.draw do
|
||||||
get 'particulier' => 'particulier#login'
|
get 'particulier' => 'particulier#login'
|
||||||
get 'particulier/callback' => 'particulier#callback'
|
get 'particulier/callback' => 'particulier#callback'
|
||||||
get 'particulier/merge/:merge_token' => 'particulier#merge', as: :particulier_merge
|
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/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_existing_account' => 'particulier#merge_with_existing_account'
|
||||||
post 'particulier/merge_with_new_account' => 'particulier#merge_with_new_account'
|
post 'particulier/merge_with_new_account' => 'particulier#merge_with_new_account'
|
||||||
|
|
|
@ -268,10 +268,10 @@ describe FranceConnect::ParticulierController, type: :controller do
|
||||||
|
|
||||||
describe '#mail_merge_with_existing_account' do
|
describe '#mail_merge_with_existing_account' do
|
||||||
let(:fci) { FranceConnectInformation.create!(user_info) }
|
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
|
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') }
|
let!(:user) { create(:user, email: email, password: 'abcdefgh') }
|
||||||
|
|
||||||
|
@ -298,8 +298,8 @@ describe FranceConnect::ParticulierController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the merge_token is not ok' do
|
context 'when the email_merge_token is not ok' do
|
||||||
subject { post :mail_merge_with_existing_account, params: { merge_token: 'ko' } }
|
subject { post :mail_merge_with_existing_account, params: { email_merge_token: 'ko' } }
|
||||||
|
|
||||||
let!(:user) { create(:user, email: email) }
|
let!(:user) { create(:user, email: email) }
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ describe FranceConnect::ParticulierController, type: :controller do
|
||||||
fci.reload
|
fci.reload
|
||||||
|
|
||||||
expect(fci.user).to be_nil
|
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(controller.current_user).to be_nil
|
||||||
expect(response).to redirect_to(root_path)
|
expect(response).to redirect_to(root_path)
|
||||||
end
|
end
|
||||||
|
@ -359,7 +359,7 @@ describe FranceConnect::ParticulierController, type: :controller do
|
||||||
subject
|
subject
|
||||||
fci.reload
|
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(controller).not_to have_received(:sign_in)
|
||||||
expect(flash[:alert]).to be_present
|
expect(flash[:alert]).to be_present
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue