refactor instruction_instructeur_avis_url

This commit is contained in:
Christophe Robillard 2020-04-20 14:47:24 +02:00
parent 72d27ffdb2
commit 83fba55b29
4 changed files with 10 additions and 6 deletions

View file

@ -37,7 +37,7 @@ module Instructeurs
def update
if @avis.update(avis_params)
flash.notice = 'Votre réponse est enregistrée.'
redirect_to instruction_instructeur_avis_path(@avis)
redirect_to instruction_instructeur_avis_path(@avis.procedure, @avis)
else
flash.now.alert = @avis.errors.full_messages
@new_avis = Avis.new
@ -65,7 +65,7 @@ module Instructeurs
@new_avis = create_avis_from_params(avis.dossier, avis.confidentiel)
if @new_avis.nil?
redirect_to instruction_instructeur_avis_path(avis)
redirect_to instruction_instructeur_avis_path(avis.procedure, avis)
else
set_avis_and_dossier
render :instruction

View file

@ -52,6 +52,10 @@ class Avis < ApplicationRecord
]
end
def procedure
dossier.procedure
end
private
def try_to_assign_instructeur

View file

@ -6,5 +6,5 @@
%ul.tabs
= dynamic_tab_item('Demande', instructeur_avis_path(avis))
= dynamic_tab_item('Avis', instruction_instructeur_avis_path(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))

View file

@ -64,7 +64,7 @@ describe Instructeurs::AvisController, type: :controller do
end
it 'should be ok' do
expect(response).to redirect_to(instruction_instructeur_avis_path(avis_without_answer))
expect(response).to redirect_to(instruction_instructeur_avis_path(avis_without_answer.procedure, avis_without_answer))
expect(avis_without_answer.answer).to eq('answer')
expect(avis_without_answer.piece_justificative_file).to_not be_attached
expect(flash.notice).to eq('Votre réponse est enregistrée.')
@ -84,7 +84,7 @@ describe Instructeurs::AvisController, type: :controller do
end
it 'should be ok' do
expect(response).to redirect_to(instruction_instructeur_avis_path(avis_without_answer))
expect(response).to redirect_to(instruction_instructeur_avis_path(avis_without_answer.procedure, avis_without_answer))
expect(avis_without_answer.answer).to eq('answer')
expect(avis_without_answer.piece_justificative_file).to be_attached
expect(flash.notice).to eq('Votre réponse est enregistrée.')
@ -178,7 +178,7 @@ describe Instructeurs::AvisController, type: :controller do
it { expect(created_avis.introduction).to eq(intro) }
it { expect(created_avis.dossier).to eq(previous_avis.dossier) }
it { expect(created_avis.claimant).to eq(instructeur) }
it { expect(response).to redirect_to(instruction_instructeur_avis_path(previous_avis)) }
it { expect(response).to redirect_to(instruction_instructeur_avis_path(previous_avis.procedure, previous_avis)) }
end
context 'when the user asked for a confidentiel avis' do