refactor instruction_instructeur_avis_url
This commit is contained in:
parent
72d27ffdb2
commit
83fba55b29
4 changed files with 10 additions and 6 deletions
|
@ -37,7 +37,7 @@ module Instructeurs
|
||||||
def update
|
def update
|
||||||
if @avis.update(avis_params)
|
if @avis.update(avis_params)
|
||||||
flash.notice = 'Votre réponse est enregistrée.'
|
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
|
else
|
||||||
flash.now.alert = @avis.errors.full_messages
|
flash.now.alert = @avis.errors.full_messages
|
||||||
@new_avis = Avis.new
|
@new_avis = Avis.new
|
||||||
|
@ -65,7 +65,7 @@ module Instructeurs
|
||||||
@new_avis = create_avis_from_params(avis.dossier, avis.confidentiel)
|
@new_avis = create_avis_from_params(avis.dossier, avis.confidentiel)
|
||||||
|
|
||||||
if @new_avis.nil?
|
if @new_avis.nil?
|
||||||
redirect_to instruction_instructeur_avis_path(avis)
|
redirect_to instruction_instructeur_avis_path(avis.procedure, avis)
|
||||||
else
|
else
|
||||||
set_avis_and_dossier
|
set_avis_and_dossier
|
||||||
render :instruction
|
render :instruction
|
||||||
|
|
|
@ -52,6 +52,10 @@ class Avis < ApplicationRecord
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def procedure
|
||||||
|
dossier.procedure
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def try_to_assign_instructeur
|
def try_to_assign_instructeur
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
|
|
||||||
%ul.tabs
|
%ul.tabs
|
||||||
= dynamic_tab_item('Demande', instructeur_avis_path(avis))
|
= 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))
|
= dynamic_tab_item('Messagerie', messagerie_instructeur_avis_path(avis))
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be ok' do
|
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.answer).to eq('answer')
|
||||||
expect(avis_without_answer.piece_justificative_file).to_not be_attached
|
expect(avis_without_answer.piece_justificative_file).to_not be_attached
|
||||||
expect(flash.notice).to eq('Votre réponse est enregistrée.')
|
expect(flash.notice).to eq('Votre réponse est enregistrée.')
|
||||||
|
@ -84,7 +84,7 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be ok' do
|
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.answer).to eq('answer')
|
||||||
expect(avis_without_answer.piece_justificative_file).to be_attached
|
expect(avis_without_answer.piece_justificative_file).to be_attached
|
||||||
expect(flash.notice).to eq('Votre réponse est enregistrée.')
|
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.introduction).to eq(intro) }
|
||||||
it { expect(created_avis.dossier).to eq(previous_avis.dossier) }
|
it { expect(created_avis.dossier).to eq(previous_avis.dossier) }
|
||||||
it { expect(created_avis.claimant).to eq(instructeur) }
|
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
|
end
|
||||||
|
|
||||||
context 'when the user asked for a confidentiel avis' do
|
context 'when the user asked for a confidentiel avis' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue