diff --git a/app/controllers/instructeurs/avis_controller.rb b/app/controllers/instructeurs/avis_controller.rb index 54081180b..4f6df0866 100644 --- a/app/controllers/instructeurs/avis_controller.rb +++ b/app/controllers/instructeurs/avis_controller.rb @@ -119,7 +119,7 @@ module Instructeurs if current_instructeur.present? # a instructeur is authenticated ... lets see if it can view the dossier - redirect_to instructeur_avis_url(avis) + redirect_to instructeur_avis_url(avis.procedure, avis) elsif avis.instructeur&.email == params[:email] # the avis instructeur has already signed up and it sould sign in diff --git a/app/helpers/dossier_link_helper.rb b/app/helpers/dossier_link_helper.rb index 93c9d9c16..8c356e925 100644 --- a/app/helpers/dossier_link_helper.rb +++ b/app/helpers/dossier_link_helper.rb @@ -6,7 +6,7 @@ module DossierLinkHelper else avis = dossier.avis.find_by(instructeur: user) if avis.present? - instructeur_avis_path(avis) + instructeur_avis_path(avis.procedure, avis) end end elsif user.owns_or_invite?(dossier) diff --git a/app/views/avis_mailer/avis_invitation.html.haml b/app/views/avis_mailer/avis_invitation.html.haml index c0f3f4272..c1c8381d5 100644 --- a/app/views/avis_mailer/avis_invitation.html.haml +++ b/app/views/avis_mailer/avis_invitation.html.haml @@ -1,5 +1,5 @@ - content_for(:title, 'Invitation à donner votre avis') -- avis_link = @avis.instructeur.present? ? instructeur_avis_url(@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.id, @avis.email) - content_for(:footer) do Merci de ne pas répondre à cet email. Donnez votre avis @@ -15,7 +15,7 @@ Vous avez été invité par %strong= @avis.claimant.email = "à donner votre avis sur le dossier nº #{@avis.dossier.id} de la démarche :" - %strong= @avis.dossier.procedure.libelle + %strong= @avis.procedure.libelle %p = "#{@avis.claimant.email} vous a écrit :" diff --git a/app/views/instructeurs/avis/_header.html.haml b/app/views/instructeurs/avis/_header.html.haml index febb8e8b2..85830909c 100644 --- a/app/views/instructeurs/avis/_header.html.haml +++ b/app/views/instructeurs/avis/_header.html.haml @@ -5,6 +5,6 @@ %li= "#{dossier.procedure.libelle}, dossier nº #{dossier.id}" %ul.tabs - = dynamic_tab_item('Demande', instructeur_avis_path(avis)) + = dynamic_tab_item('Demande', instructeur_avis_path(avis.procedure, avis)) = dynamic_tab_item('Avis', instruction_instructeur_avis_path(avis.procedure, avis), notification: avis.answer.blank?) = dynamic_tab_item('Messagerie', messagerie_instructeur_avis_path(avis.procedure, avis)) diff --git a/app/views/instructeurs/avis/index.html.haml b/app/views/instructeurs/avis/index.html.haml index cf1232d47..dddb3946b 100644 --- a/app/views/instructeurs/avis/index.html.haml +++ b/app/views/instructeurs/avis/index.html.haml @@ -29,11 +29,11 @@ - @avis.each do |avis| %tr %td.number-col - = link_to(instructeur_avis_path(avis), class: 'cell-link') do + = link_to(instructeur_avis_path(avis.procedure, avis), class: 'cell-link') do %span.icon.folder #{avis.dossier.id} - %td= link_to(avis.dossier.user.email, instructeur_avis_path(avis), class: 'cell-link') - %td= link_to(avis.dossier.procedure.libelle, instructeur_avis_path(avis), class: 'cell-link') + %td= link_to(avis.dossier.user.email, instructeur_avis_path(avis.procedure, avis), class: 'cell-link') + %td= link_to(avis.procedure.libelle, instructeur_avis_path(avis.procedure, avis), class: 'cell-link') = paginate(@avis) - else %h2.empty-text Aucun avis diff --git a/app/views/instructeurs/avis/instruction.html.haml b/app/views/instructeurs/avis/instruction.html.haml index c891620c1..1cefc6aea 100644 --- a/app/views/instructeurs/avis/instruction.html.haml +++ b/app/views/instructeurs/avis/instruction.html.haml @@ -15,7 +15,7 @@ = render partial: 'shared/attachment/show', locals: { attachment: @avis.introduction_file.attachment } %br/ - = form_for @avis, url: instructeur_avis_path(@avis), html: { class: 'form' } do |f| + = form_for @avis, url: instructeur_avis_path(@avis.procedure, @avis), html: { class: 'form' } do |f| = f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true = render 'shared/attachment/edit', { form: f, @@ -35,7 +35,7 @@ = f.submit 'Envoyer votre avis', class: 'button send' - if !@dossier.termine? - = render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_avis_path(@avis), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } + = render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } - if @dossier.avis_for(current_instructeur).present? = render partial: 'instructeurs/shared/avis/list', locals: { avis: @dossier.avis_for(current_instructeur), avis_seen_at: nil } diff --git a/spec/controllers/instructeurs/avis_controller_spec.rb b/spec/controllers/instructeurs/avis_controller_spec.rb index cbcc3579d..b62173e13 100644 --- a/spec/controllers/instructeurs/avis_controller_spec.rb +++ b/spec/controllers/instructeurs/avis_controller_spec.rb @@ -290,7 +290,7 @@ describe Instructeurs::AvisController, type: :controller do get :sign_up, params: { id: avis.id, procedure_id: procedure.id, email: invited_email } end - it { is_expected.to redirect_to instructeur_avis_url(avis) } + it { is_expected.to redirect_to instructeur_avis_url(avis.procedure, avis) } end context 'when the instructeur is not authenticated' do @@ -312,7 +312,7 @@ describe Instructeurs::AvisController, type: :controller do end # redirected to dossier but then the instructeur gonna be banished ! - it { is_expected.to redirect_to instructeur_avis_url(avis) } + it { is_expected.to redirect_to instructeur_avis_url(avis.procedure, avis) } end end diff --git a/spec/helpers/dossier_link_helper_spec.rb b/spec/helpers/dossier_link_helper_spec.rb index 7b43b37ec..c8f04fab1 100644 --- a/spec/helpers/dossier_link_helper_spec.rb +++ b/spec/helpers/dossier_link_helper_spec.rb @@ -29,7 +29,7 @@ describe DossierLinkHelper do let(:instructeur) { create(:instructeur) } let!(:avis) { create(:avis, dossier: dossier, instructeur: instructeur) } - it { expect(helper.dossier_linked_path(instructeur, dossier)).to eq(instructeur_avis_path(avis)) } + it { expect(helper.dossier_linked_path(instructeur, dossier)).to eq(instructeur_avis_path(avis.dossier.procedure, avis)) } end context "when access as user" do diff --git a/spec/mailers/avis_mailer_spec.rb b/spec/mailers/avis_mailer_spec.rb index ff9f5bd7d..75b61d27b 100644 --- a/spec/mailers/avis_mailer_spec.rb +++ b/spec/mailers/avis_mailer_spec.rb @@ -7,7 +7,7 @@ RSpec.describe AvisMailer, type: :mailer do it { expect(subject.subject).to eq("Donnez votre avis sur le dossier nº #{avis.dossier.id} (#{avis.dossier.procedure.libelle})") } it { expect(subject.body).to have_text("Vous avez été invité par\r\n#{avis.claimant.email}\r\nà donner votre avis sur le dossier nº #{avis.dossier.id} de la démarche :\r\n#{avis.dossier.procedure.libelle}") } it { expect(subject.body).to include(avis.introduction) } - it { expect(subject.body).to include(instructeur_avis_url(avis)) } + it { expect(subject.body).to include(instructeur_avis_url(avis.dossier.procedure.id, avis)) } context 'when the recipient is not already registered' do before do