Add Backoffice::DossiersController#process_dossier and use it
This commit is contained in:
parent
1bff7d1914
commit
33944e343a
5 changed files with 59 additions and 13 deletions
|
@ -103,6 +103,17 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
redirect_to backoffice_dossier_path(id: dossier.id)
|
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def process_dossier
|
||||||
|
case params[:process_action]
|
||||||
|
when "refuse"
|
||||||
|
refuse
|
||||||
|
when "without_continuation"
|
||||||
|
without_continuation
|
||||||
|
when "close"
|
||||||
|
close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def refuse
|
def refuse
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
|
|
@ -8,16 +8,19 @@
|
||||||
= link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" }
|
= link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" }
|
||||||
|
|
||||||
- elsif @facade.dossier.received?
|
- elsif @facade.dossier.received?
|
||||||
%ul.list-inline
|
= form_tag(backoffice_dossier_process_dossier_url(@facade.dossier.id), method: :post) do
|
||||||
%li
|
%ul.list-inline
|
||||||
= link_to url_for({ controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id }), class: 'btn btn-success', method: :post, title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
|
%li
|
||||||
%i.fa.fa-check
|
= button_tag name: :process_action, value: "close", class: 'btn btn-success', title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
|
||||||
%li
|
%i.fa.fa-check
|
||||||
= link_to url_for({ controller: 'backoffice/dossiers', action: :without_continuation, dossier_id: @facade.dossier.id }), class: 'btn btn-warning', method: :post, title: 'Classer sans suite', data: { toggle: :tooltip, confirm: "Classer sans suite ce dossier ?" } do
|
|
||||||
%i.fa.fa-circle-o
|
%li
|
||||||
%li
|
= button_tag name: :process_action, value: "without_continuation", class: 'btn btn-warning', title: 'Classer sans suite', data: { toggle: :tooltip, confirm: "Classer sans suite ce dossier ?" } do
|
||||||
= link_to url_for({ controller: 'backoffice/dossiers', action: :refuse, dossier_id: @facade.dossier.id }), class: 'btn btn-danger', method: :post, title: 'Refuser', data: { toggle: :tooltip, confirm: "Refuser ce dossier ?" } do
|
%i.fa.fa-circle-o
|
||||||
%i.fa.fa-times
|
|
||||||
|
%li
|
||||||
|
= button_tag name: :process_action, value: "refuse", class: 'btn btn-danger', title: 'Refuser', data: { toggle: :tooltip, confirm: "Refuser ce dossier ?" } do
|
||||||
|
%i.fa.fa-times
|
||||||
|
|
||||||
= link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous la réouverture de ce dossier ?" }
|
= link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous la réouverture de ce dossier ?" }
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
post 'receive' => 'dossiers#receive'
|
post 'receive' => 'dossiers#receive'
|
||||||
|
post 'process_dossier' => 'dossiers#process_dossier'
|
||||||
post 'refuse' => 'dossiers#refuse'
|
post 'refuse' => 'dossiers#refuse'
|
||||||
post 'without_continuation' => 'dossiers#without_continuation'
|
post 'without_continuation' => 'dossiers#without_continuation'
|
||||||
post 'close' => 'dossiers#close'
|
post 'close' => 'dossiers#close'
|
||||||
|
|
|
@ -250,6 +250,37 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) }
|
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'POST #process_dossier' do
|
||||||
|
before do
|
||||||
|
dossier.received!
|
||||||
|
sign_in gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with refuse" do
|
||||||
|
it "calls the refuse method" do
|
||||||
|
expect(controller).to receive(:refuse)
|
||||||
|
|
||||||
|
post :process_dossier, params: { dossier_id: dossier_id, process_action: "refuse" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with without_continuation" do
|
||||||
|
it "calls the without_continuation method" do
|
||||||
|
expect(controller).to receive(:without_continuation)
|
||||||
|
|
||||||
|
post :process_dossier, params: { dossier_id: dossier_id, process_action: "without_continuation" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with close" do
|
||||||
|
it "calls the close method" do
|
||||||
|
expect(controller).to receive(:close)
|
||||||
|
|
||||||
|
post :process_dossier, params: { dossier_id: dossier_id, process_action: "close" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'POST #refuse' do
|
describe 'POST #refuse' do
|
||||||
before do
|
before do
|
||||||
dossier.received!
|
dossier.received!
|
||||||
|
|
|
@ -74,9 +74,9 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
||||||
it { expect(rendered).to have_content('En instruction') }
|
it { expect(rendered).to have_content('En instruction') }
|
||||||
|
|
||||||
it 'button accepter / refuser / classer sans suite are present' do
|
it 'button accepter / refuser / classer sans suite are present' do
|
||||||
expect(rendered).to have_css('a[title="Accepter"]')
|
expect(rendered).to have_css('button[title="Accepter"]')
|
||||||
expect(rendered).to have_css('a[title="Classer sans suite"]')
|
expect(rendered).to have_css('button[title="Classer sans suite"]')
|
||||||
expect(rendered).to have_css('a[title="Refuser"]')
|
expect(rendered).to have_css('button[title="Refuser"]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue