NewDesign: add archive and unarchive actions on dossier
This commit is contained in:
parent
eb65318844
commit
a064ae64a4
3 changed files with 33 additions and 0 deletions
|
@ -14,6 +14,16 @@ module NewGestionnaire
|
|||
redirect_back(fallback_location: procedures_url)
|
||||
end
|
||||
|
||||
def archive
|
||||
dossier.update_attributes(archived: true)
|
||||
redirect_back(fallback_location: procedures_url)
|
||||
end
|
||||
|
||||
def unarchive
|
||||
dossier.update_attributes(archived: false)
|
||||
redirect_back(fallback_location: procedures_url)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dossier
|
||||
|
|
|
@ -244,6 +244,8 @@ Rails.application.routes.draw do
|
|||
get 'attestation'
|
||||
patch 'follow'
|
||||
patch 'unfollow'
|
||||
patch 'archive'
|
||||
patch 'unarchive'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,4 +43,25 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it { expect(gestionnaire.followed_dossiers).to match([]) }
|
||||
it { expect(response).to redirect_to(procedures_url) }
|
||||
end
|
||||
|
||||
describe 'archive' do
|
||||
before do
|
||||
patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.archived).to be true }
|
||||
it { expect(response).to redirect_to(procedures_url) }
|
||||
end
|
||||
|
||||
describe 'unarchive' do
|
||||
before do
|
||||
dossier.update_attributes(archived: true)
|
||||
patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.archived).to be false }
|
||||
it { expect(response).to redirect_to(procedures_url) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue