Merge pull request #5996 from betagouv/fix-dossier-link
fix dossier link helper
This commit is contained in:
commit
806469d72e
3 changed files with 7 additions and 20 deletions
|
@ -4,11 +4,6 @@ module DossierLinkHelper
|
|||
if user.groupe_instructeurs.include?(dossier.groupe_instructeur)
|
||||
instructeur_dossier_path(dossier.procedure, dossier)
|
||||
end
|
||||
elsif user.is_a?(Expert)
|
||||
avis = dossier.avis.find_by(expert: user.user)
|
||||
if avis.present?
|
||||
expert_avis_path(avis.procedure, avis)
|
||||
end
|
||||
elsif user.owns_or_invite?(dossier)
|
||||
dossier_path(dossier)
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ feature 'Inviting an expert:' do
|
|||
|
||||
let(:instructeur) { create(:instructeur, password: 'my-s3cure-p4ssword') }
|
||||
let(:expert) { create(:expert, password: expert_password) }
|
||||
let(:expert2) { create(:expert, password: expert_password) }
|
||||
let(:expert_password) { 'mot de passe d’expert' }
|
||||
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :with_dossier_link, procedure: procedure) }
|
||||
|
@ -20,7 +21,7 @@ feature 'Inviting an expert:' do
|
|||
click_on 'Avis externes'
|
||||
expect(page).to have_current_path(avis_instructeur_dossier_path(procedure, dossier))
|
||||
|
||||
fill_in 'avis_emails', with: 'expert1@expert.com, expert2@expert.com'
|
||||
fill_in 'avis_emails', with: "#{expert.email}, #{expert2.email}"
|
||||
fill_in 'avis_introduction', with: 'Bonjour, merci de me donner votre avis sur ce dossier.'
|
||||
check 'avis_invite_linked_dossiers'
|
||||
page.select 'confidentiel', from: 'avis_confidentiel'
|
||||
|
@ -31,16 +32,16 @@ feature 'Inviting an expert:' do
|
|||
expect(page).to have_content('Une demande d\'avis a été envoyée')
|
||||
expect(page).to have_content('Avis des invités')
|
||||
within('.list-avis') do
|
||||
expect(page).to have_content('expert1@expert.com')
|
||||
expect(page).to have_content('expert2@expert.com')
|
||||
expect(page).to have_content(expert.email.to_s)
|
||||
expect(page).to have_content(expert2.email.to_s)
|
||||
expect(page).to have_content('Bonjour, merci de me donner votre avis sur ce dossier.')
|
||||
end
|
||||
|
||||
expect(Avis.count).to eq(4)
|
||||
expect(emails_sent_to('expert1@expert.com').size).to eq(1)
|
||||
expect(emails_sent_to('expert2@expert.com').size).to eq(1)
|
||||
expect(emails_sent_to(expert.email.to_s).size).to eq(1)
|
||||
expect(emails_sent_to(expert2.email.to_s).size).to eq(1)
|
||||
|
||||
invitation_email = open_email('expert1@expert.com')
|
||||
invitation_email = open_email(expert.email.to_s)
|
||||
avis = Avis.find_by(expert: expert.id)
|
||||
sign_up_link = sign_up_expert_avis_path(avis.dossier.procedure, avis, avis.expert.email)
|
||||
expect(invitation_email.body).to include(sign_up_link)
|
||||
|
|
|
@ -24,15 +24,6 @@ describe DossierLinkHelper do
|
|||
it { expect(helper.dossier_linked_path(instructeur, dossier)).to eq(instructeur_dossier_path(dossier.procedure, dossier)) }
|
||||
end
|
||||
|
||||
context "when access as expert" do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let!(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: dossier.procedure) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
it { expect(helper.dossier_linked_path(expert, dossier)).to eq(expert_avis_path(avis.dossier.procedure, avis)) }
|
||||
end
|
||||
|
||||
context "when access as user" do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:user) { create(:user) }
|
||||
|
|
Loading…
Reference in a new issue