diff --git a/app/helpers/collection_time_helper.rb b/app/helpers/collection_time_helper.rb index 34426bab2..ea7601c70 100644 --- a/app/helpers/collection_time_helper.rb +++ b/app/helpers/collection_time_helper.rb @@ -13,7 +13,8 @@ module CollectionTimeHelper end def date_mid_collection_year_formatted(date) - example_date = date.nil? ? Time.zone.today : collection_start_date(date).to_date + 5.months + relevant_year = date.nil? ? current_collection_start_year : collection_start_year_for_date(date) + example_date = Date.new(relevant_year, 9, 13) example_date.to_formatted_s(:govuk_date_number_month) end diff --git a/spec/helpers/collection_time_helper_spec.rb b/spec/helpers/collection_time_helper_spec.rb index e9ec52292..3eef01b5e 100644 --- a/spec/helpers/collection_time_helper_spec.rb +++ b/spec/helpers/collection_time_helper_spec.rb @@ -85,9 +85,9 @@ RSpec.describe CollectionTimeHelper do context "when called with nil" do let(:input) { nil } - it "returns the current date" do - today = Time.zone.today - expect(result).to eq("#{today.day} #{today.month} #{today.year}") + it "returns the 13th of September in the current collection year" do + year = current_collection_start_year + expect(result).to eq("13 9 #{year}") end end @@ -95,8 +95,8 @@ RSpec.describe CollectionTimeHelper do calendar_year = 2030 let(:input) { Date.new(calendar_year, 7, 7) } - it "returns the first of September from that year" do - expect(result).to eq("1 9 #{calendar_year}") + it "returns the 13th of September from that year" do + expect(result).to eq("13 9 #{calendar_year}") end end @@ -104,8 +104,8 @@ RSpec.describe CollectionTimeHelper do calendar_year = 2040 let(:input) { Date.new(calendar_year, 2, 7) } - it "returns the first of September from the previous year" do - expect(result).to eq("1 9 #{calendar_year - 1}") + it "returns the 13th of September from the previous year" do + expect(result).to eq("13 9 #{calendar_year - 1}") end end end