2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
describe 'administrateurs/procedures/zones' do
|
2024-06-01 22:50:48 +02:00
|
|
|
let(:administrateur) { administrateurs(:default_admin) }
|
2022-09-26 19:02:39 +02:00
|
|
|
let(:procedure) { create(:procedure) }
|
2023-03-27 15:35:27 +02:00
|
|
|
let(:populate_zones_task) { Rake::Task['after_party:populate_zones_with_tchap_hs'] }
|
2022-09-26 19:02:39 +02:00
|
|
|
|
|
|
|
before do
|
2022-12-20 09:22:28 +01:00
|
|
|
Rails.application.config.ds_zonage_enabled = true
|
2022-09-26 19:02:39 +02:00
|
|
|
populate_zones_task.invoke
|
2023-03-27 15:35:27 +02:00
|
|
|
allow(view).to receive(:current_administrateur).and_return(administrateur)
|
2022-09-26 19:02:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
populate_zones_task.reenable
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure has never been published' do
|
|
|
|
before { Timecop.freeze(now) }
|
|
|
|
after { Timecop.return }
|
|
|
|
|
|
|
|
let(:procedure) { create(:procedure, zones: [Zone.find_by(acronym: 'MTEI')]) }
|
|
|
|
let(:now) { Time.zone.parse('18/05/2022') }
|
|
|
|
|
|
|
|
it 'displays zones with label available at the creation date' do
|
|
|
|
assign(:procedure, procedure)
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_content("Ministère du Travail")
|
|
|
|
expect(rendered).not_to have_content("Ministère du Travail, du Plein emploi et de l'Insertion")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure has been published' do
|
|
|
|
before { Timecop.freeze(now) }
|
|
|
|
after { Timecop.return }
|
|
|
|
|
|
|
|
let(:procedure) { create(:procedure, zones: [Zone.find_by(acronym: 'MTEI')]) }
|
|
|
|
let(:now) { Time.zone.parse('18/05/2022') }
|
|
|
|
|
|
|
|
it 'displays zones with label available at the creation date' do
|
|
|
|
Timecop.freeze(Time.zone.parse('22/05/2022')) do
|
|
|
|
procedure.publish!
|
|
|
|
end
|
|
|
|
|
|
|
|
assign(:procedure, procedure)
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_content("Ministère du Travail, du Plein emploi et de l'Insertion")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|