From f809689e0ebfd36231f0eaa2b49a7f5b2da6e01c Mon Sep 17 00:00:00 2001 From: David May-Miller Date: Fri, 25 Jul 2025 18:13:47 +0100 Subject: [PATCH] CLDC-4074 Updated sales log tests to use filters from the current year instead of a fixed one --- spec/features/sales_log_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb index 212804c46..39e21bf85 100644 --- a/spec/features/sales_log_spec.rb +++ b/spec/features/sales_log_spec.rb @@ -4,6 +4,7 @@ RSpec.describe "Sales Log Features" do context "when searching for specific sales logs" do context "when I am signed in and there are sales logs in the database" do let(:user) { FactoryBot.create(:user, last_sign_in_at: Time.zone.now, name: "Jimbo") } + let(:current_year) { current_collection_start_year } let!(:log_to_search) { FactoryBot.create(:sales_log, owning_organisation: user.organisation) } let!(:same_organisation_log) { FactoryBot.create(:sales_log, owning_organisation: user.organisation) } let!(:another_organisation_log) { FactoryBot.create(:sales_log) } @@ -161,7 +162,7 @@ RSpec.describe "Sales Log Features" do expect(page).to have_selector(".govuk-error-summary__title") expect(page).to have_content("There is a problem") - choose("years-2023-field", allow_label_click: true) + choose("years-#{current_year}-field", allow_label_click: true) click_button("Save changes") expect(page).to have_current_path("/sales-logs/csv-download?codes_only=false&search=1") @@ -175,7 +176,7 @@ RSpec.describe "Sales Log Features" do expect(page).to have_selector(".govuk-error-summary__title") expect(page).to have_content("There is a problem") - choose("years-2023-field", allow_label_click: true) + choose("years-#{current_year}-field", allow_label_click: true) click_button("Save changes") expect(page).to have_current_path("/sales-logs/csv-download?codes_only=true&search=1")