2019-02-13 16:13:37 +01:00
|
|
|
describe Manager::DossiersController, type: :controller do
|
2020-11-05 15:09:11 +01:00
|
|
|
let(:super_admin) { create :super_admin }
|
2020-03-26 17:35:50 +01:00
|
|
|
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier) }
|
|
|
|
let(:operations) { dossier.dossier_operation_logs.map(&:operation).map(&:to_sym) }
|
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
before { sign_in super_admin }
|
2020-03-26 17:35:50 +01:00
|
|
|
|
2020-03-25 18:08:32 +01:00
|
|
|
describe '#discard' do
|
2020-03-26 17:35:50 +01:00
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
2019-02-13 16:13:37 +01:00
|
|
|
|
|
|
|
before do
|
2020-03-25 18:08:32 +01:00
|
|
|
post :discard, params: { id: dossier.id }
|
2019-02-13 16:13:37 +01:00
|
|
|
dossier.reload
|
|
|
|
end
|
|
|
|
|
2020-03-25 18:08:32 +01:00
|
|
|
it { expect(dossier.discarded?).to be_truthy }
|
2020-03-26 17:35:50 +01:00
|
|
|
it { expect(deleted_dossier).not_to be_nil }
|
|
|
|
it { expect(deleted_dossier.reason).to eq("manager_request") }
|
|
|
|
it { expect(operations).to eq([:supprimer]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#restore' do
|
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
|
|
|
|
|
|
|
before do
|
2020-11-05 15:09:11 +01:00
|
|
|
dossier.discard_and_keep_track!(super_admin, :manager_request)
|
2020-03-26 17:35:50 +01:00
|
|
|
|
|
|
|
post :restore, params: { id: dossier.id }
|
|
|
|
dossier.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(dossier.kept?).to be_truthy }
|
|
|
|
it { expect(deleted_dossier).to be_nil }
|
|
|
|
it { expect(operations).to eq([:supprimer, :restaurer]) }
|
2019-02-13 16:13:37 +01:00
|
|
|
end
|
2019-07-29 10:57:21 +02:00
|
|
|
|
|
|
|
describe '#repasser_en_instruction' do
|
2020-03-25 18:08:32 +01:00
|
|
|
let(:dossier) { create(:dossier, :accepte) }
|
2019-07-29 10:57:21 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
post :repasser_en_instruction, params: { id: dossier.id }
|
|
|
|
dossier.reload
|
|
|
|
end
|
|
|
|
|
2020-03-25 18:08:32 +01:00
|
|
|
it { expect(dossier.en_instruction?).to be_truthy }
|
2019-07-29 10:57:21 +02:00
|
|
|
end
|
2019-02-13 16:13:37 +01:00
|
|
|
end
|