routes: replace the email param in the Avis URLs by a query param

This commit is contained in:
Pierre de La Morinerie 2021-06-15 16:44:33 +00:00
parent ab442cd8d1
commit b5bde6608c
7 changed files with 14 additions and 9 deletions

View file

@ -91,7 +91,7 @@ module Experts
redirect_to url_for(expert_all_avis_path)
else
flash[:alert] = user.errors.full_messages
redirect_to url_for(sign_up_expert_avis_path(procedure_id, avis_id, email))
redirect_to sign_up_expert_avis_path(procedure_id, avis_id, email: email)
end
end

View file

@ -1,5 +1,5 @@
- content_for(:title, 'Invitation à donner votre avis')
- avis_link = @avis.expert.user.active?.present? ? expert_avis_url(@avis.procedure, @avis) : sign_up_expert_avis_url(@avis.procedure, @avis.id, @avis.expert.email)
- avis_link = @avis.expert.user.active?.present? ? expert_avis_url(@avis.procedure, @avis) : sign_up_expert_avis_url(@avis.procedure, @avis.id, email: @avis.expert.email)
- content_for(:footer) do
Merci de ne pas répondre à cet email. Donnez votre avis

View file

@ -4,7 +4,7 @@
%p.description= @dossier.procedure.libelle
%p.dossier Dossier nº #{@dossier.id}
.column
= form_for(User.new, url: { controller: "experts/avis", action: :update_expert }, method: :post, html: { class: "form" }) do |f|
= form_for(User.new, url: sign_up_expert_avis_path(email: @email), method: :post, html: { class: "form" }) do |f|
%h1 Créez-vous un compte
= f.label :email, "Email"

View file

@ -313,8 +313,13 @@ Rails.application.routes.draw do
post 'avis' => 'avis#create_avis'
get 'bilans_bdf'
get 'sign_up/email/:email' => 'avis#sign_up', constraints: { email: /.*/ }, as: 'sign_up'
post 'sign_up/email/:email' => 'avis#update_expert', constraints: { email: /.*/ }
get 'sign_up' => 'avis#sign_up'
post 'sign_up' => 'avis#update_expert'
# This redirections are ephemeral, to ensure that emails sent to experts before are still valid
# TODO : remove these lines after September, 2021
get 'sign_up/email/:email' => 'avis#sign_up', constraints: { email: /.*/ }, as: 'sign_up_legacy'
post 'sign_up/email/:email' => 'avis#update_expert', constraints: { email: /.*/ }, as: 'update_expert_legacy'
end
end
end

View file

@ -12,7 +12,7 @@ feature 'Inviting an expert:' do
context 'when I dont already have an account' do
scenario 'I can sign up' do
visit sign_up_expert_avis_path(avis.dossier.procedure, avis, avis.expert.email)
visit sign_up_expert_avis_path(avis.dossier.procedure, avis, email: avis.expert.email)
expect(page).to have_field('Email', with: avis.expert.email, disabled: true)
fill_in 'Mot de passe', with: 'This is a very complicated password !'
@ -29,7 +29,7 @@ feature 'Inviting an expert:' do
avis.expert.user.reload
end
scenario 'I can sign in' do
visit sign_up_expert_avis_path(avis.dossier.procedure, avis, avis.expert.email)
visit sign_up_expert_avis_path(avis.dossier.procedure, avis, email: avis.expert.email)
expect(page).to have_current_path(new_user_session_path)
login_as avis.expert.user, scope: :user

View file

@ -45,7 +45,7 @@ feature 'Inviting an expert:', js: true do
invitation_email = open_email(expert.email.to_s)
avis = expert.avis.find_by(dossier: dossier)
sign_up_link = sign_up_expert_avis_path(avis.dossier.procedure, avis, avis.expert.email)
sign_up_link = sign_up_expert_avis_path(avis.dossier.procedure, avis, email: avis.expert.email)
expect(invitation_email.body).to include(sign_up_link)
end

View file

@ -14,7 +14,7 @@ RSpec.describe AvisMailer, type: :mailer do
it { expect(subject.body).to include(instructeur_avis_url(avis.dossier.procedure.id, avis)) }
context 'when the recipient is not already registered' do
it { expect(subject.body).to include(sign_up_expert_avis_url(avis.dossier.procedure.id, avis.id, avis.expert.email)) }
it { expect(subject.body).to include(sign_up_expert_avis_url(avis.dossier.procedure.id, avis.id, email: avis.expert.email)) }
end
context 'when the dossier has been deleted before the avis was sent' do