demarches-normaliennes/spec/controllers/manager/procedures_controller_spec.rb

81 lines
2.2 KiB
Ruby
Raw Normal View History

2021-10-04 12:17:07 +02:00
describe Manager::ProceduresController, type: :controller do
let(:super_admin) { create :super_admin }
before { sign_in super_admin }
describe '#whitelist' do
2020-03-26 09:08:52 +01:00
let(:procedure) { create(:procedure) }
before do
post :whitelist, params: { id: procedure.id }
procedure.reload
end
it { expect(procedure.whitelisted?).to be_truthy }
end
describe '#show' do
render_views
let(:procedure) { create(:procedure, :published, :with_repetition) }
before do
get :show, params: { id: procedure.id }
end
it { expect(response.body).to include('sub type de champ') }
end
2020-03-26 09:08:52 +01:00
describe '#discard' 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) }
2020-03-26 09:08:52 +01:00
before do
post :discard, params: { id: procedure.id }
procedure.reload
dossier.reload
2020-03-26 09:08:52 +01:00
end
it { expect(procedure.discarded?).to be_truthy }
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
2021-01-28 13:53:18 +01:00
let(:dossier) { create(:dossier, :en_construction, :with_individual) }
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!(super_admin)
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
describe '#index' do
render_views
context 'sort by dossiers' do
let!(:dossier) { create(:dossier) }
before do
2021-05-05 21:34:57 +02:00
get :index, params: { procedure: { direction: :asc, order: :dossiers } }
end
it { expect(response.body).to include('1 dossier') }
end
end
end