From 119df7cf46b3af50c51f09ccf16aa9e2a6339f7a Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Thu, 19 Mar 2026 09:33:34 +0000 Subject: [PATCH] CLDC-4325: Fix collection resources controller spec --- .../collection_resources_controller_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/requests/collection_resources_controller_spec.rb b/spec/requests/collection_resources_controller_spec.rb index 812a6eaf1..51ccf830c 100644 --- a/spec/requests/collection_resources_controller_spec.rb +++ b/spec/requests/collection_resources_controller_spec.rb @@ -49,12 +49,16 @@ RSpec.describe CollectionResourcesController, type: :request do let(:user) { create(:user, :support) } before do - allow(Time.zone).to receive(:today).and_return(Time.zone.local(2025, 1, 8)) + Timecop.travel(Time.zone.local(current_collection_start_year, 1, 8)) allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(storage_service).to receive(:file_exists?).and_return(true) sign_in user end + after do + Timecop.return + end + it "displays collection resources" do get collection_resources_path @@ -122,7 +126,7 @@ RSpec.describe CollectionResourcesController, type: :request do context "when the collection year has not started yet" do before do - Timecop.freeze(Time.zone.local(2025, 3, 1)) + Timecop.freeze(Time.zone.local(current_collection_start_year, 3, 1)) get collection_resources_path end @@ -131,8 +135,8 @@ RSpec.describe CollectionResourcesController, type: :request do end it "displays next year banner" do - expect(page).to have_content("The 2025 to 2026 collection resources are not yet available to users.") - expect(page).to have_link("Release the 2025 to 2026 collection resources to users", href: confirm_mandatory_collection_resources_release_path(year: 2025)) + expect(page).to have_content("The #{next_collection_start_year} to #{next_collection_end_year} collection resources are not yet available to users.") + expect(page).to have_link("Release the #{next_collection_start_year} to #{next_collection_end_year} collection resources to users", href: confirm_mandatory_collection_resources_release_path(year: next_collection_start_year)) end end @@ -176,7 +180,7 @@ RSpec.describe CollectionResourcesController, type: :request do context "when the collection year has not started yet" do before do - Timecop.freeze(Time.zone.local(2025, 3, 1)) + Timecop.freeze(Time.zone.local(current_collection_start_year, 3, 1)) get collection_resources_path end @@ -185,8 +189,8 @@ RSpec.describe CollectionResourcesController, type: :request do end it "displays next year banner" do - expect(page).to have_content("The 2025 to 2026 collection resources are not yet available to users.") - expect(page).to have_content("Once you have uploaded all the required 2025 to 2026 collection resources, you will be able to release them to users.") + expect(page).to have_content("The #{next_collection_start_year} to #{next_collection_end_year} collection resources are not yet available to users.") + expect(page).to have_content("Once you have uploaded all the required #{next_collection_start_year} to #{next_collection_end_year} collection resources, you will be able to release them to users.") end end end