diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index 6a12cff29..678ef044f 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -1,5 +1,6 @@ module TasklistHelper include GovukLinkHelper + include CollectionTimeHelper def get_next_incomplete_section(log) log.form.subsections.find { |subsection| subsection.is_incomplete?(log) } @@ -34,7 +35,9 @@ module TasklistHelper "You can #{govuk_link_to 'review and make changes to this log', link} until #{log.form.end_date.to_formatted_s(:govuk_date)}.".html_safe else - "This log is from the #{log.form.start_date.year}/#{log.form.start_date.year + 1} collection window, which is now closed." + start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year + + "This log is from the #{start_year}/#{start_year + 1} collection window, which is now closed." end end diff --git a/spec/helpers/tasklist_helper_spec.rb b/spec/helpers/tasklist_helper_spec.rb index 3d4874632..ac6075fd2 100644 --- a/spec/helpers/tasklist_helper_spec.rb +++ b/spec/helpers/tasklist_helper_spec.rb @@ -131,10 +131,19 @@ RSpec.describe TasklistHelper do it "returns relevant text" do Timecop.freeze(now + 1.year) do - expect(review_log_text(sales_log)).to eq("This log is from the 2021/2022 collection window, which is now closed.") + expect(review_log_text(sales_log)).to eq("This log is from the 2022/2023 collection window, which is now closed.") end end end + + context "when older_than_previous_collection_year" do + let(:now) { Time.utc(2023, 6, 1) } + let(:sales_log) { build(:sales_log, :completed, saledate: Time.utc(2022, 2, 1)) } + + it "returns relevant text" do + expect(review_log_text(sales_log)).to eq("This log is from the 2021/2022 collection window, which is now closed.") + end + end end context "with lettings log" do @@ -168,10 +177,19 @@ RSpec.describe TasklistHelper do it "returns relevant text" do Timecop.freeze(now + 1.year) do - expect(review_log_text(sales_log)).to eq("This log is from the 2021/2022 collection window, which is now closed.") + expect(review_log_text(sales_log)).to eq("This log is from the 2022/2023 collection window, which is now closed.") end end end + + context "when older_than_previous_collection_year" do + let(:now) { Time.utc(2023, 6, 1) } + let(:lettings_log) { build(:lettings_log, :completed, startdate: Time.utc(2022, 2, 1)) } + + it "returns relevant text" do + expect(review_log_text(lettings_log)).to eq("This log is from the 2021/2022 collection window, which is now closed.") + end + end end end end