Merge branch 'archive_dossier' into develop

This commit is contained in:
Xavier J 2017-02-13 13:41:50 +01:00
commit e4b0638762
4 changed files with 35 additions and 1 deletions

View file

@ -158,6 +158,15 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
render 'backoffice/dossiers/index', formats: :js
end
def archive
facade = create_dossier_facade params[:dossier_id]
unless facade.dossier.archived
facade.dossier.update(archived: true)
flash.notice = 'Dossier archivé'
end
redirect_to backoffice_dossiers_path
end
private
def create_dossier_facade dossier_id

View file

@ -24,6 +24,11 @@
%button.action.refuse-dossier
%i.fa.fa-times
- unless @facade.dossier.archived?
= link_to 'Archiver', backoffice_dossier_archive_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
%div#menu-block
%div#infos-block
@ -33,7 +38,7 @@
%div.split-hr-left
%div.notifications
- if @facade.dossier.notifications.empty?
= "Aucune notification pour le moment."
Aucune notification pour le moment.
- else
%i.fa.fa-bell-o
- @facade.last_notifications.each do |notification|

View file

@ -172,6 +172,7 @@ Rails.application.routes.draw do
post 'refuse' => 'dossiers#refuse'
post 'without_continuation' => 'dossiers#without_continuation'
post 'close' => 'dossiers#close'
post 'archive' => 'dossiers#archive'
put 'follow' => 'dossiers#follow'
resources :commentaires, only: [:index]

View file

@ -345,4 +345,23 @@ describe Backoffice::DossiersController, type: :controller do
end
end
end
describe 'POST #archive' do
before do
dossier.update(archived: false)
sign_in gestionnaire
end
subject { post :archive, params: {dossier_id: dossier_id} }
it 'change state to archived' do
subject
dossier.reload
expect(dossier.archived).to eq(true)
end
it { is_expected.to redirect_to backoffice_dossiers_path }
end
end