Add button archive on procedure

This commit is contained in:
Xavier J 2015-11-26 18:41:41 +01:00
parent 02453e4cb1
commit 833752161f
9 changed files with 132 additions and 13 deletions

View file

@ -166,4 +166,36 @@ describe Admin::ProceduresController, type: :controller do
end
end
end
describe 'PUT #archive' do
let(:procedure) { create(:procedure, administrateur: admin) }
context 'when admin is the owner of the procedure' do
before do
put :archive, procedure_id: procedure.id
procedure.reload
end
it { expect(procedure.archived).to be_truthy }
it { expect(response).to redirect_to :admin_procedures }
it { expect(flash[:notice]).to have_content 'Procédure archivée' }
end
context 'when admin is not the owner of the procedure' do
let(:admin_2) { create(:administrateur) }
before do
sign_out admin
sign_in admin_2
put :archive, procedure_id: procedure.id
procedure.reload
end
it { expect(response).to redirect_to :admin_procedures }
it { expect(flash[:alert]).to have_content 'Procédure inéxistante' }
end
end
end