Browse Source

[CLDC-2240] Show correct copy when log older than previous collection year (#1569)

CLDC-2227-move-uprn-questions
Jack 2 years ago committed by GitHub
parent
commit
9fb44d7aef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/helpers/tasklist_helper.rb
  2. 22
      spec/helpers/tasklist_helper_spec.rb

5
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

22
spec/helpers/tasklist_helper_spec.rb

@ -131,9 +131,18 @@ 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
@ -168,8 +177,17 @@ 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

Loading…
Cancel
Save