2021-10-04 12:17:07 +02:00
|
|
|
describe Manager::ProceduresController, 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
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
before { sign_in super_admin }
|
2020-03-26 17:35:50 +01:00
|
|
|
|
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
|
2022-01-12 11:31:05 +01:00
|
|
|
let(:dossier) { create(:dossier, :accepte) }
|
2020-03-26 17:35:50 +01:00
|
|
|
let(:procedure) { dossier.procedure }
|
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 }
|
2022-01-12 11:31:05 +01:00
|
|
|
it { expect(dossier.hidden_by_administration?).to be_truthy }
|
2020-03-26 17:35:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#restore' do
|
2022-01-12 11:31:05 +01:00
|
|
|
let(:dossier) { create(:dossier, :accepte, :with_individual) }
|
2020-03-26 17:35:50 +01:00
|
|
|
let(:procedure) { dossier.procedure }
|
|
|
|
|
|
|
|
before do
|
2020-11-05 15:09:11 +01:00
|
|
|
procedure.discard_and_keep_track!(super_admin)
|
2020-03-26 17:35:50 +01:00
|
|
|
|
|
|
|
post :restore, params: { id: procedure.id }
|
|
|
|
procedure.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(procedure.kept?).to be_truthy }
|
2022-01-12 11:31:05 +01:00
|
|
|
it { expect(dossier.hidden_by_administration?).to be_falsey }
|
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
|
2021-05-05 21:34:57 +02:00
|
|
|
get :index, params: { procedure: { direction: :asc, order: :dossiers } }
|
2020-03-05 12:57:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response.body).to include('1 dossier') }
|
|
|
|
end
|
|
|
|
end
|
2018-01-10 16:46:12 +01:00
|
|
|
end
|