|
|
|
@ -1,7 +1,7 @@ |
|
|
|
require "rails_helper" |
|
|
|
require "rails_helper" |
|
|
|
|
|
|
|
|
|
|
|
RSpec.describe TasklistHelper do |
|
|
|
RSpec.describe TasklistHelper do |
|
|
|
let(:now) { Time.utc(2022, 6, 1) } |
|
|
|
let(:now) { Time.utc(2022, 1, 1) } |
|
|
|
|
|
|
|
|
|
|
|
around do |example| |
|
|
|
around do |example| |
|
|
|
Timecop.freeze(now) do |
|
|
|
Timecop.freeze(now) do |
|
|
|
@ -14,7 +14,7 @@ RSpec.describe TasklistHelper do |
|
|
|
|
|
|
|
|
|
|
|
describe "with lettings" do |
|
|
|
describe "with lettings" do |
|
|
|
let(:empty_lettings_log) { create(:lettings_log) } |
|
|
|
let(:empty_lettings_log) { create(:lettings_log) } |
|
|
|
let(:lettings_log) { build(:lettings_log, :in_progress, needstype: 1) } |
|
|
|
let(:lettings_log) { build(:lettings_log, :in_progress, needstype: 1, startdate: now) } |
|
|
|
|
|
|
|
|
|
|
|
describe "get next incomplete section" do |
|
|
|
describe "get next incomplete section" do |
|
|
|
it "returns the first subsection name if it is not completed" do |
|
|
|
it "returns the first subsection name if it is not completed" do |
|
|
|
@ -28,8 +28,15 @@ RSpec.describe TasklistHelper do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "get sections count" do |
|
|
|
describe "get sections count" do |
|
|
|
|
|
|
|
let(:fake_2021_2022_form) { Form.new("spec/fixtures/forms/2021_2022.json") } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(FormHandler.instance).to receive(:get_form).and_return(fake_2021_2022_form) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the total of sections if no status is given" do |
|
|
|
it "returns the total of sections if no status is given" do |
|
|
|
expect(get_subsections_count(empty_lettings_log)).to eq(1) |
|
|
|
expect(get_subsections_count(empty_lettings_log)).to eq(8) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns 0 sections for completed sections if no sections are completed" do |
|
|
|
it "returns 0 sections for completed sections if no sections are completed" do |
|
|
|
@ -37,7 +44,7 @@ RSpec.describe TasklistHelper do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the number of not started sections" do |
|
|
|
it "returns the number of not started sections" do |
|
|
|
expect(get_subsections_count(empty_lettings_log, :not_started)).to eq(1) |
|
|
|
expect(get_subsections_count(empty_lettings_log, :not_started)).to eq(8) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the number of sections in progress" do |
|
|
|
it "returns the number of sections in progress" do |
|
|
|
@ -49,41 +56,6 @@ RSpec.describe TasklistHelper do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "review_log_text" do |
|
|
|
|
|
|
|
context "when collection_period_open? == true" do |
|
|
|
|
|
|
|
context "with 2023 deadline" do |
|
|
|
|
|
|
|
let(:now) { Time.utc(2022, 6, 1) } |
|
|
|
|
|
|
|
let(:lettings_log) { create(:lettings_log, :completed) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns relevant text" do |
|
|
|
|
|
|
|
expect(review_log_text(lettings_log)).to eq( |
|
|
|
|
|
|
|
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 1 July 2023.".html_safe, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with 2024 deadline" do |
|
|
|
|
|
|
|
let(:now) { Time.utc(2023, 6, 20) } |
|
|
|
|
|
|
|
let(:lettings_log) { create(:lettings_log, :completed, national: 18, waityear: 2) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns relevant text" do |
|
|
|
|
|
|
|
expect(review_log_text(lettings_log)).to eq( |
|
|
|
|
|
|
|
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 9 July 2024.".html_safe, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when collection_period_open? == false" do |
|
|
|
|
|
|
|
let(:now) { Time.utc(2023, 7, 8) } |
|
|
|
|
|
|
|
let(:lettings_log) { create(:lettings_log, :completed, startdate: Time.utc(2023, 2, 8)) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns relevant text" do |
|
|
|
|
|
|
|
expect(review_log_text(lettings_log)).to eq("This log is from the 2022/2023 collection window, which is now closed.") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "subsection link" do |
|
|
|
describe "subsection link" do |
|
|
|
let(:lettings_log) { create(:lettings_log, :completed) } |
|
|
|
let(:lettings_log) { create(:lettings_log, :completed) } |
|
|
|
let(:subsection) { lettings_log.form.get_subsection("household_characteristics") } |
|
|
|
let(:subsection) { lettings_log.form.get_subsection("household_characteristics") } |
|
|
|
@ -131,5 +103,42 @@ RSpec.describe TasklistHelper do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with lettings log" do |
|
|
|
|
|
|
|
context "when collection_period_open? == true" do |
|
|
|
|
|
|
|
context "with 2023 deadline" do |
|
|
|
|
|
|
|
let(:now) { Time.utc(2022, 6, 1) } |
|
|
|
|
|
|
|
let(:lettings_log) { create(:lettings_log, :completed) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns relevant text" do |
|
|
|
|
|
|
|
expect(review_log_text(lettings_log)).to eq( |
|
|
|
|
|
|
|
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 1 July 2023.".html_safe, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with 2024 deadline" do |
|
|
|
|
|
|
|
let(:now) { Time.utc(2023, 6, 20) } |
|
|
|
|
|
|
|
let(:lettings_log) { create(:lettings_log, :completed, national: 18, waityear: 2) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns relevant text" do |
|
|
|
|
|
|
|
expect(review_log_text(lettings_log)).to eq( |
|
|
|
|
|
|
|
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 9 July 2024.".html_safe, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when collection_period_open? == false" do |
|
|
|
|
|
|
|
let(:now) { Time.utc(2022, 6, 1) } |
|
|
|
|
|
|
|
let!(:sales_log) { create(:lettings_log, :completed) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|