refactor sign_up_instructeur_avis_url
This commit is contained in:
parent
b0aa005769
commit
c565c9c87b
5 changed files with 9 additions and 7 deletions
|
@ -89,6 +89,8 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_instructeur
|
def create_instructeur
|
||||||
|
procedure_id = params[:procedure_id]
|
||||||
|
avis_id = params[:id]
|
||||||
email = params[:email]
|
email = params[:email]
|
||||||
password = params[:user][:password]
|
password = params[:user][:password]
|
||||||
|
|
||||||
|
@ -102,7 +104,7 @@ module Instructeurs
|
||||||
redirect_to url_for(instructeur_all_avis_path)
|
redirect_to url_for(instructeur_all_avis_path)
|
||||||
else
|
else
|
||||||
flash[:alert] = user.errors.full_messages
|
flash[:alert] = user.errors.full_messages
|
||||||
redirect_to url_for(sign_up_instructeur_avis_path(params[:id], email))
|
redirect_to url_for(sign_up_instructeur_avis_path(procedure_id, avis_id, email))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- content_for(:title, 'Invitation à donner votre avis')
|
- content_for(:title, 'Invitation à donner votre avis')
|
||||||
- avis_link = @avis.instructeur.present? ? instructeur_avis_url(@avis.procedure, @avis) : sign_up_instructeur_avis_url(@avis.id, @avis.email)
|
- avis_link = @avis.instructeur.present? ? instructeur_avis_url(@avis.procedure, @avis) : sign_up_instructeur_avis_url(@avis.procedure, @avis.id, @avis.email)
|
||||||
|
|
||||||
- content_for(:footer) do
|
- content_for(:footer) do
|
||||||
Merci de ne pas répondre à cet email. Donnez votre avis
|
Merci de ne pas répondre à cet email. Donnez votre avis
|
||||||
|
|
|
@ -378,7 +378,7 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
let(:password) { '' }
|
let(:password) { '' }
|
||||||
|
|
||||||
it { expect(created_instructeur).to be_nil }
|
it { expect(created_instructeur).to be_nil }
|
||||||
it { is_expected.to redirect_to sign_up_instructeur_avis_path(avis_id, invited_email) }
|
it { is_expected.to redirect_to sign_up_instructeur_avis_path(procedure.id, avis_id, invited_email) }
|
||||||
it { expect(flash.alert).to eq(['Le mot de passe doit être rempli']) }
|
it { expect(flash.alert).to eq(['Le mot de passe doit être rempli']) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,7 @@ feature 'Inviting an expert:' do
|
||||||
|
|
||||||
invitation_email = open_email('expert2@exemple.fr')
|
invitation_email = open_email('expert2@exemple.fr')
|
||||||
avis = Avis.find_by(email: 'expert2@exemple.fr', dossier: dossier)
|
avis = Avis.find_by(email: 'expert2@exemple.fr', dossier: dossier)
|
||||||
sign_up_link = sign_up_instructeur_avis_path(avis.id, avis.email)
|
sign_up_link = sign_up_instructeur_avis_path(avis.dossier.procedure, avis, avis.email)
|
||||||
expect(invitation_email.body).to include(sign_up_link)
|
expect(invitation_email.body).to include(sign_up_link)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ feature 'Inviting an expert:' do
|
||||||
let(:avis_email) { 'not-signed-up-expert@exemple.fr' }
|
let(:avis_email) { 'not-signed-up-expert@exemple.fr' }
|
||||||
|
|
||||||
scenario 'I can sign up' do
|
scenario 'I can sign up' do
|
||||||
visit sign_up_instructeur_avis_path(avis.id, avis_email)
|
visit sign_up_instructeur_avis_path(avis.dossier.procedure, avis, avis_email)
|
||||||
|
|
||||||
expect(page).to have_field('Email', with: avis_email, disabled: true)
|
expect(page).to have_field('Email', with: avis_email, disabled: true)
|
||||||
fill_in 'Mot de passe', with: 'This is a very complicated password !'
|
fill_in 'Mot de passe', with: 'This is a very complicated password !'
|
||||||
|
@ -86,7 +86,7 @@ feature 'Inviting an expert:' do
|
||||||
let(:avis_email) { expert.email }
|
let(:avis_email) { expert.email }
|
||||||
|
|
||||||
scenario 'I can sign in' do
|
scenario 'I can sign in' do
|
||||||
visit sign_up_instructeur_avis_path(avis.id, avis_email)
|
visit sign_up_instructeur_avis_path(avis.dossier.procedure, avis, avis_email)
|
||||||
|
|
||||||
expect(page).to have_current_path(new_user_session_path)
|
expect(page).to have_current_path(new_user_session_path)
|
||||||
sign_in_with(expert.email, expert_password)
|
sign_in_with(expert.email, expert_password)
|
||||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe AvisMailer, type: :mailer do
|
||||||
avis.instructeur = nil
|
avis.instructeur = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject.body).to include(sign_up_instructeur_avis_url(avis.id, avis.email)) }
|
it { expect(subject.body).to include(sign_up_instructeur_avis_url(avis.dossier.procedure.id, avis.id, avis.email)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue