refactor instructeur_avis_url
This commit is contained in:
parent
b0cfb2c02a
commit
4839506374
9 changed files with 14 additions and 14 deletions
|
@ -119,7 +119,7 @@ module Instructeurs
|
||||||
if current_instructeur.present?
|
if current_instructeur.present?
|
||||||
# a instructeur is authenticated ... lets see if it can view the dossier
|
# 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]
|
elsif avis.instructeur&.email == params[:email]
|
||||||
# the avis instructeur has already signed up and it sould sign in
|
# the avis instructeur has already signed up and it sould sign in
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module DossierLinkHelper
|
||||||
else
|
else
|
||||||
avis = dossier.avis.find_by(instructeur: user)
|
avis = dossier.avis.find_by(instructeur: user)
|
||||||
if avis.present?
|
if avis.present?
|
||||||
instructeur_avis_path(avis)
|
instructeur_avis_path(avis.procedure, avis)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif user.owns_or_invite?(dossier)
|
elsif user.owns_or_invite?(dossier)
|
||||||
|
|
|
@ -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) : 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
|
- 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
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
Vous avez été invité par
|
Vous avez été invité par
|
||||||
%strong= @avis.claimant.email
|
%strong= @avis.claimant.email
|
||||||
= "à donner votre avis sur le dossier nº #{@avis.dossier.id} de la démarche :"
|
= "à donner votre avis sur le dossier nº #{@avis.dossier.id} de la démarche :"
|
||||||
%strong= @avis.dossier.procedure.libelle
|
%strong= @avis.procedure.libelle
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= "#{@avis.claimant.email} vous a écrit :"
|
= "#{@avis.claimant.email} vous a écrit :"
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
%li= "#{dossier.procedure.libelle}, dossier nº #{dossier.id}"
|
%li= "#{dossier.procedure.libelle}, dossier nº #{dossier.id}"
|
||||||
|
|
||||||
%ul.tabs
|
%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('Avis', instruction_instructeur_avis_path(avis.procedure, avis), notification: avis.answer.blank?)
|
||||||
= dynamic_tab_item('Messagerie', messagerie_instructeur_avis_path(avis.procedure, avis))
|
= dynamic_tab_item('Messagerie', messagerie_instructeur_avis_path(avis.procedure, avis))
|
||||||
|
|
|
@ -29,11 +29,11 @@
|
||||||
- @avis.each do |avis|
|
- @avis.each do |avis|
|
||||||
%tr
|
%tr
|
||||||
%td.number-col
|
%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
|
%span.icon.folder
|
||||||
#{avis.dossier.id}
|
#{avis.dossier.id}
|
||||||
%td= link_to(avis.dossier.user.email, 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.dossier.procedure.libelle, instructeur_avis_path(avis), class: 'cell-link')
|
%td= link_to(avis.procedure.libelle, instructeur_avis_path(avis.procedure, avis), class: 'cell-link')
|
||||||
= paginate(@avis)
|
= paginate(@avis)
|
||||||
- else
|
- else
|
||||||
%h2.empty-text Aucun avis
|
%h2.empty-text Aucun avis
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
= render partial: 'shared/attachment/show', locals: { attachment: @avis.introduction_file.attachment }
|
= render partial: 'shared/attachment/show', locals: { attachment: @avis.introduction_file.attachment }
|
||||||
%br/
|
%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
|
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||||
= render 'shared/attachment/edit',
|
= render 'shared/attachment/edit',
|
||||||
{ form: f,
|
{ form: f,
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
= f.submit 'Envoyer votre avis', class: 'button send'
|
= f.submit 'Envoyer votre avis', class: 'button send'
|
||||||
|
|
||||||
- if !@dossier.termine?
|
- 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?
|
- if @dossier.avis_for(current_instructeur).present?
|
||||||
= render partial: 'instructeurs/shared/avis/list', locals: { avis: @dossier.avis_for(current_instructeur), avis_seen_at: nil }
|
= render partial: 'instructeurs/shared/avis/list', locals: { avis: @dossier.avis_for(current_instructeur), avis_seen_at: nil }
|
||||||
|
|
|
@ -290,7 +290,7 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
get :sign_up, params: { id: avis.id, procedure_id: procedure.id, email: invited_email }
|
get :sign_up, params: { id: avis.id, procedure_id: procedure.id, email: invited_email }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to instructeur_avis_url(avis) }
|
it { is_expected.to redirect_to instructeur_avis_url(avis.procedure, avis) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the instructeur is not authenticated' do
|
context 'when the instructeur is not authenticated' do
|
||||||
|
@ -312,7 +312,7 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
# redirected to dossier but then the instructeur gonna be banished !
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe DossierLinkHelper do
|
||||||
let(:instructeur) { create(:instructeur) }
|
let(:instructeur) { create(:instructeur) }
|
||||||
let!(:avis) { create(:avis, dossier: dossier, instructeur: 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
|
end
|
||||||
|
|
||||||
context "when access as user" do
|
context "when access as user" do
|
||||||
|
|
|
@ -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.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 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(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
|
context 'when the recipient is not already registered' do
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue