parent
467268f4dd
commit
44511acfed
8 changed files with 61 additions and 40 deletions
|
@ -77,14 +77,14 @@ module NewGestionnaire
|
|||
current_gestionnaire.follow(dossier)
|
||||
flash.notice = 'Dossier passé en instruction.'
|
||||
|
||||
redirect_to gestionnaire_dossier_path(procedure, dossier)
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
||||
def repasser_en_construction
|
||||
dossier.en_construction!
|
||||
flash.notice = 'Dossier repassé en construction.'
|
||||
|
||||
redirect_to gestionnaire_dossier_path(procedure, dossier)
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
||||
def terminer
|
||||
|
@ -113,7 +113,7 @@ module NewGestionnaire
|
|||
NotificationMailer.send_closed_notification(dossier).deliver_later
|
||||
end
|
||||
|
||||
redirect_to gestionnaire_dossier_path(procedure, dossier)
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
||||
def create_commentaire
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import $ from 'jquery';
|
||||
|
||||
export function showMotivation(state) {
|
||||
export function showMotivation(event, state) {
|
||||
event.preventDefault();
|
||||
$(`.motivation.${state}`).show();
|
||||
$('.dropdown-items').hide();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
|
||||
|
||||
= render partial: "new_gestionnaire/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) }
|
||||
%span.state-button
|
||||
= render partial: "state_button", locals: { dossier: dossier }
|
||||
|
||||
%ul.tabs
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
%h4 En construction
|
||||
Vous permettez à l'usager de modifier ses réponses au formulaire
|
||||
%li
|
||||
= link_to passer_en_instruction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
|
||||
= link_to passer_en_instruction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { remote: true, confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
|
||||
%span.icon.in-progress
|
||||
.description
|
||||
%h4 Passer en instruction
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
- if dossier.en_instruction?
|
||||
%li
|
||||
= link_to repasser_en_construction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en construction de ce dossier ?" } do
|
||||
= link_to repasser_en_construction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Confirmer vous le passage en construction de ce dossier ?" } do
|
||||
%span.icon.edit
|
||||
.description
|
||||
%h4 Repasser en construction
|
||||
|
@ -29,17 +29,20 @@
|
|||
.description
|
||||
%h4 En instruction
|
||||
L'usager ne peut modifier son dossier pendant l'instruction
|
||||
%li{ onclick: "DS.showMotivation('accept');" }
|
||||
%li
|
||||
%a{ href: '#', onclick: "DS.showMotivation(event, 'accept');" }
|
||||
%span.icon.accept
|
||||
.description
|
||||
%h4 Accepter
|
||||
L'usager sera notifié que son dossier a été accepté
|
||||
%li{ onclick: "DS.showMotivation('without-continuation');" }
|
||||
%li
|
||||
%a{ href: '#', onclick: "DS.showMotivation(event, 'without-continuation');" }
|
||||
%span.icon.without-continuation
|
||||
.description
|
||||
%h4 Classer sans suite
|
||||
L'usager sera notifié que son dossier a été classé sans suite
|
||||
%li{ onclick: "DS.showMotivation('refuse');" }
|
||||
%li
|
||||
%a{ href: '#', onclick: "DS.showMotivation(event, 'refuse');" }
|
||||
%span.icon.refuse
|
||||
.description
|
||||
%h4 Refuser
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
%span.icon{ class: popup_class }
|
||||
#{popup_title}
|
||||
|
||||
= form_tag(terminer_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, class: 'form') do
|
||||
= form_tag(terminer_gestionnaire_dossier_path(dossier.procedure, dossier), remote: true, method: :post, class: 'form') do
|
||||
- if title == 'Accepter'
|
||||
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: 'Rédigez votre motivation ici (facultative)', required: false
|
||||
%p.help
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<%= render_flash %>
|
||||
<%= render_to_element('.state-button', partial: "state_button", locals: { dossier: dossier }) %>
|
|
@ -107,12 +107,12 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
before do
|
||||
dossier.en_construction!
|
||||
sign_in gestionnaire
|
||||
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
||||
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js'
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||
it { is_expected.to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
||||
it { expect(response.body).to include('.state-button') }
|
||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||
end
|
||||
|
||||
|
@ -122,7 +122,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||
|
||||
it 'change state to en_construction' do
|
||||
subject
|
||||
|
@ -131,7 +131,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
expect(dossier.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
||||
it { expect(subject.body).to include('.state-button') }
|
||||
end
|
||||
|
||||
describe '#terminer' do
|
||||
|
@ -141,7 +141,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||
|
||||
it 'change state to refuse' do
|
||||
subject
|
||||
|
@ -158,7 +158,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
||||
it { expect(subject.body).to include('.state-button') }
|
||||
end
|
||||
|
||||
context "with classer_sans_suite" do
|
||||
|
@ -167,7 +167,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||
|
||||
it 'change state to sans_suite' do
|
||||
subject
|
||||
|
@ -184,7 +184,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
||||
it { expect(subject.body).to include('.state-button') }
|
||||
end
|
||||
|
||||
context "with accepter" do
|
||||
|
@ -199,7 +199,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
expect(NotificationMailer).to receive(:deliver_later)
|
||||
end
|
||||
|
||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||
|
||||
it 'change state to accepte' do
|
||||
subject
|
||||
|
@ -223,16 +223,14 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
it 'The gestionnaire is sent back to the dossier page' do
|
||||
subject
|
||||
|
||||
is_expected.to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
|
||||
expect(subject.body).to include('.state-button')
|
||||
end
|
||||
|
||||
context 'and the dossier has already an attestation' do
|
||||
it 'should not crash' do
|
||||
dossier.attestation = Attestation.new
|
||||
dossier.save
|
||||
expect(subject).to redirect_to redirect_to gestionnaire_dossier_path(procedure, dossier)
|
||||
expect(subject.body).to include('.state-button')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -248,7 +246,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id,
|
||||
dossier: { motivation: "Yallah" }
|
||||
}
|
||||
}, format: 'js'
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -9,7 +9,7 @@ feature 'The gestionnaire part' do
|
|||
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
||||
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
||||
|
||||
scenario 'A gestionnaire can accept a dossier' do
|
||||
scenario 'A gestionnaire can accept a dossier', :js do
|
||||
log_in(gestionnaire.email, password)
|
||||
|
||||
expect(page).to have_current_path(gestionnaire_procedures_path)
|
||||
|
@ -20,14 +20,30 @@ feature 'The gestionnaire part' do
|
|||
click_on dossier.user.email
|
||||
expect(page).to have_current_path(gestionnaire_dossier_path(procedure, dossier))
|
||||
|
||||
click_on 'En construction'
|
||||
accept_confirm do
|
||||
click_on 'Passer en instruction'
|
||||
end
|
||||
expect(page).to have_text('En instruction')
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||
|
||||
click_on 'En instruction'
|
||||
|
||||
within('.dropdown-items') do
|
||||
click_on 'Accepter'
|
||||
end
|
||||
|
||||
within('.accept.motivation') do
|
||||
fill_in('dossier_motivation', with: 'a good reason')
|
||||
|
||||
accept_confirm do
|
||||
click_on 'Valider la décision'
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_text('Dossier traité avec succès.')
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
||||
|
|
Loading…
Reference in a new issue