demarches-normaliennes/spec/controllers/instructeurs/archives_controller_spec.rb
Martin 3737311390 feat(procedure.procedure_expires_when_termine_enabled): enable by default, allow contributor to choose the default settings of this flag using an env var during migration. ie: DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true|false
feat(administrateurs/procedures#show): warning/alert when procedure_expires_when_termine_enabled is not true on current procedure

feat(administrateur/procedure#update): after an update redirect to procedure show: suggested by: https://ux.stackexchange.com/questions/55291/after-updating-form-should-redirect-back-to-form-itself-or-to-the-show-page-or-b and confirmed by Olivier

clean(Flipper.archive_zip_globale): no more in use, so remove all occurences

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update spec/views/administrateurs/procedures/show.html.haml_spec.rb

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

fix(review): typo, why ena?, who knows

fix(env.example.optional): add missing DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED
2022-05-05 13:07:11 +02:00

52 lines
1.8 KiB
Ruby

describe Instructeurs::ArchivesController, type: :controller do
let(:procedure1) { create(:procedure, :published, groupe_instructeurs: [gi1]) }
let(:procedure2) { create(:procedure, :published, groupe_instructeurs: [gi2]) }
let!(:instructeur) { create(:instructeur, groupe_instructeurs: [gi1, gi2]) }
let!(:archive1) { create(:archive, :generated, groupe_instructeurs: [gi1]) }
let!(:archive2) { create(:archive, :generated, groupe_instructeurs: [gi2]) }
let(:gi1) { create(:groupe_instructeur) }
let(:gi2) { create(:groupe_instructeur) }
before do
sign_in(instructeur.user)
end
after { Timecop.return }
describe '#index' do
before do
create_dossier_for_month(procedure1, 2021, 3)
create_dossier_for_month(procedure1, 2021, 3)
create_dossier_for_month(procedure1, 2021, 2)
Timecop.freeze(Time.zone.local(2021, 3, 5))
end
it 'displays archives' do
get :index, params: { procedure_id: procedure1.id }
expect(assigns(:archives)).to eq([archive1])
end
end
describe '#create' do
let(:month) { '21-03' }
let(:date_month) { Date.strptime(month, "%Y-%m") }
let(:archive) { create(:archive) }
let(:subject) do
post :create, params: { procedure_id: procedure1.id, type: 'monthly', month: month }
end
it "performs archive creation job" do
allow_any_instance_of(ProcedureArchiveService).to receive(:create_pending_archive).and_return(archive)
expect { subject }.to have_enqueued_job(ArchiveCreationJob).with(procedure1, archive, instructeur)
expect(flash.notice).to include("Votre demande a été prise en compte")
end
end
private
def create_dossier_for_month(procedure, year, month)
Timecop.freeze(Time.zone.local(year, month, 5))
create(:dossier, :accepte, :with_attestation, procedure: procedure)
end
end