2018-01-10 16:46:12 +01:00
|
|
|
describe Manager::ProceduresController, type: :controller do
|
2020-03-26 17:35:50 +01:00
|
|
|
let(:administration) { create :administration }
|
|
|
|
|
|
|
|
before { sign_in administration }
|
|
|
|
|
2018-01-10 16:46:12 +01:00
|
|
|
describe '#whitelist' do
|
2020-03-26 09:08:52 +01:00
|
|
|
let(:procedure) { create(:procedure) }
|
2018-01-10 16:46:12 +01:00
|
|
|
|
|
|
|
before do
|
2018-01-23 18:16:44 +01:00
|
|
|
post :whitelist, params: { id: procedure.id }
|
2018-01-10 16:46:12 +01:00
|
|
|
procedure.reload
|
|
|
|
end
|
|
|
|
|
2020-03-26 17:35:50 +01:00
|
|
|
it { expect(procedure.whitelisted?).to be_truthy }
|
2018-01-10 16:46:12 +01:00
|
|
|
end
|
2020-02-07 15:35:09 +01:00
|
|
|
|
|
|
|
describe '#show' do
|
|
|
|
render_views
|
|
|
|
|
2020-08-27 19:56:48 +02:00
|
|
|
let(:procedure) { create(:procedure, :published, :with_repetition) }
|
2020-02-07 15:35:09 +01:00
|
|
|
|
|
|
|
before do
|
|
|
|
get :show, params: { id: procedure.id }
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response.body).to include('sub type de champ') }
|
|
|
|
end
|
2020-03-05 12:57:28 +01:00
|
|
|
|
2020-03-26 09:08:52 +01:00
|
|
|
describe '#discard' do
|
2020-03-26 17:35:50 +01:00
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
|
|
|
let(:procedure) { dossier.procedure }
|
|
|
|
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier.id) }
|
|
|
|
let(:operations) { dossier.dossier_operation_logs.map(&:operation).map(&:to_sym) }
|
2020-03-26 09:08:52 +01:00
|
|
|
|
|
|
|
before do
|
|
|
|
post :discard, params: { id: procedure.id }
|
|
|
|
procedure.reload
|
2020-03-26 17:35:50 +01:00
|
|
|
dossier.reload
|
2020-03-26 09:08:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(procedure.discarded?).to be_truthy }
|
2020-03-26 17:35:50 +01:00
|
|
|
it { expect(dossier.discarded?).to be_truthy }
|
|
|
|
it { expect(deleted_dossier).not_to be_nil }
|
|
|
|
it { expect(deleted_dossier.reason).to eq("procedure_removed") }
|
|
|
|
it { expect(operations).to eq([:supprimer]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#restore' do
|
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
|
|
|
let(:procedure) { dossier.procedure }
|
|
|
|
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier.id) }
|
|
|
|
let(:operations) { dossier.dossier_operation_logs.map(&:operation).map(&:to_sym) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
procedure.discard_and_keep_track!(administration)
|
|
|
|
|
|
|
|
post :restore, params: { id: procedure.id }
|
|
|
|
procedure.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(procedure.kept?).to be_truthy }
|
|
|
|
it { expect(dossier.kept?).to be_truthy }
|
|
|
|
it { expect(deleted_dossier).to be_nil }
|
|
|
|
it { expect(operations).to eq([:supprimer, :restaurer]) }
|
2020-03-26 09:08:52 +01:00
|
|
|
end
|
|
|
|
|
2020-03-05 12:57:28 +01:00
|
|
|
describe '#index' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
context 'sort by dossiers' do
|
2020-03-26 17:35:50 +01:00
|
|
|
let!(:dossier) { create(:dossier) }
|
|
|
|
|
2020-03-05 12:57:28 +01:00
|
|
|
before do
|
|
|
|
get :index, params: { procedure: { direction: 'asc', order: 'dossiers' } }
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response.body).to include('1 dossier') }
|
|
|
|
end
|
|
|
|
end
|
2018-01-10 16:46:12 +01:00
|
|
|
end
|