tests
This commit is contained in:
parent
4d7392e70f
commit
51b8d8f254
1 changed files with 23 additions and 1 deletions
|
@ -351,7 +351,7 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
describe 'PUT #archive' do
|
||||
let(:procedure) { create(:procedure, :published, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
|
||||
context 'when the admin is an owner of the procedure' do
|
||||
context 'when the admin is an owner of the procedure without procedure replacement' do
|
||||
before do
|
||||
put :archive, params: { procedure_id: procedure.id }
|
||||
procedure.reload
|
||||
|
@ -362,6 +362,28 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
expect(response).to redirect_to :admin_procedures
|
||||
expect(flash[:notice]).to have_content 'Démarche close'
|
||||
end
|
||||
|
||||
it 'does not have any replacement procedure' do
|
||||
expect(procedure.replaced_by_procedure).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the admin is an owner of the procedure with procedure replacement' do
|
||||
let(:new_procedure) { create(:procedure, :published, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
before do
|
||||
put :archive, params: { procedure_id: procedure.id, new_procedure: new_procedure }
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it 'archives the procedure' do
|
||||
expect(procedure.close?).to be_truthy
|
||||
expect(response).to redirect_to :admin_procedures
|
||||
expect(flash[:notice]).to have_content 'Démarche close'
|
||||
end
|
||||
|
||||
it 'does have a replacement procedure' do
|
||||
expect(procedure.replaced_by_procedure).to eq(new_procedure)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the admin is not an owner of the procedure' do
|
||||
|
|
Loading…
Reference in a new issue