From c48bd78526e6b141449d0a4ebe33512f307ce85b Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 29 Jun 2023 14:27:10 +0100 Subject: [PATCH] Update new logs end date --- app/models/form.rb | 8 ++------ spec/requests/locations_controller_spec.rb | 21 ++++++++++----------- spec/requests/schemes_controller_spec.rb | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/models/form.rb b/app/models/form.rb index cee9694d4..437785cd8 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -6,11 +6,7 @@ class Form def initialize(form_path, start_year = "", sections_in_form = [], type = "lettings") if sales_or_start_year_after_2022?(type, start_year) @start_date = Time.zone.local(start_year, 4, 1) - @new_logs_end_date = if start_year && start_year.to_i > 2022 - Time.zone.local(start_year + 1, 6, 9) - else - Time.zone.local(start_year + 1, 8, 7) - end + @new_logs_end_date = Time.zone.local(start_year + 1, 12, 29) # this is to be manually updated each year when we want to stop users from creating new logs @submission_deadline = if start_year && start_year.to_i > 2022 Time.zone.local(start_year + 1, 6, 7) else @@ -43,7 +39,7 @@ class Form @pages = subsections.flat_map(&:pages) @questions = pages.flat_map(&:questions) @start_date = Time.iso8601(form_definition["start_date"]) - @new_logs_end_date = Time.iso8601(form_definition["end_date"]) + @new_logs_end_date = Time.zone.local(@start_date.year + 1, 12, 29) @submission_deadline = Time.zone.local(@start_date.year + 1, 6, 9) @edit_end_date = Time.zone.local(@start_date.year + 1, 12, 31) @unresolved_log_redirect_page_id = form_definition["unresolved_log_redirect_page_id"] diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index edc5dc452..48eb703ca 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -1401,7 +1401,7 @@ RSpec.describe LocationsController, type: :request do let(:setup_locations) { nil } before do - Timecop.freeze(Time.utc(2022, 10, 10)) + Timecop.freeze(Time.utc(2023, 10, 10)) sign_in user add_deactivations setup_locations @@ -1608,7 +1608,7 @@ RSpec.describe LocationsController, type: :request do end end - context "when the date is entered is before the beginning of current collection window" do + context "when the date entered is before the beginning of current collection window" do let(:params) { { location_deactivation_period: { deactivation_date_type: "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "4", "deactivation_date(1i)": "2020" } } } it "displays the new page with an error message" do @@ -1656,9 +1656,9 @@ RSpec.describe LocationsController, type: :request do end context "when there is an earlier open deactivation" do - let(:deactivation_date) { Time.zone.local(2022, 10, 10) } - let(:params) { { location_deactivation_period: { deactivation_date_type: "other", "deactivation_date(3i)": "8", "deactivation_date(2i)": "9", "deactivation_date(1i)": "2023" } } } - let(:add_deactivations) { create(:location_deactivation_period, deactivation_date: Time.zone.local(2023, 6, 5), reactivation_date: nil, location:) } + let(:deactivation_date) { Time.zone.local(2023, 10, 10) } + let(:params) { { location_deactivation_period: { deactivation_date_type: "other", "deactivation_date(3i)": "8", "deactivation_date(2i)": "9", "deactivation_date(1i)": "2024" } } } + let(:add_deactivations) { create(:location_deactivation_period, deactivation_date: Time.zone.local(2024, 6, 5), reactivation_date: nil, location:) } it "redirects to the location page and updates the existing deactivation period" do follow_redirect! @@ -1667,14 +1667,13 @@ RSpec.describe LocationsController, type: :request do expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") location.reload expect(location.location_deactivation_periods.count).to eq(1) - expect(location.location_deactivation_periods.first.deactivation_date).to eq(Time.zone.local(2023, 9, 8)) + expect(location.location_deactivation_periods.first.deactivation_date).to eq(Time.zone.local(2024, 9, 8)) end end context "when there is a later open deactivation" do - let(:deactivation_date) { Time.zone.local(2022, 10, 10) } let(:params) { { location_deactivation_period: { deactivation_date_type: "other", "deactivation_date(3i)": "8", "deactivation_date(2i)": "9", "deactivation_date(1i)": "2022" } } } - let(:add_deactivations) { create(:location_deactivation_period, deactivation_date: Time.zone.local(2023, 6, 5), reactivation_date: nil, location:) } + let(:add_deactivations) { create(:location_deactivation_period, deactivation_date: Time.zone.local(2024, 6, 5), reactivation_date: nil, location:) } it "redirects to the confirmation page" do follow_redirect! @@ -1833,7 +1832,7 @@ RSpec.describe LocationsController, type: :request do let(:startdate) { Time.utc(2022, 9, 11) } before do - Timecop.freeze(Time.utc(2022, 9, 10)) + Timecop.freeze(Time.utc(2023, 1, 10)) sign_in user create(:location_deactivation_period, deactivation_date:, location:) location.save! @@ -1882,13 +1881,13 @@ RSpec.describe LocationsController, type: :request do end context "with other future date" do - let(:params) { { location_deactivation_period: { reactivation_date_type: "other", "reactivation_date(3i)": "14", "reactivation_date(2i)": "12", "reactivation_date(1i)": "2022" } } } + let(:params) { { location_deactivation_period: { reactivation_date_type: "other", "reactivation_date(3i)": "14", "reactivation_date(2i)": "12", "reactivation_date(1i)": "2023" } } } it "redirects to the location page and displays a success banner" do expect(response).to redirect_to("/schemes/#{scheme.id}/locations/#{location.id}") follow_redirect! expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") - expect(page).to have_content("#{location.name} will reactivate on 14 December 2022") + expect(page).to have_content("#{location.name} will reactivate on 14 December 2023") end end diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 754d8cb22..f8aab4d40 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -1893,7 +1893,7 @@ RSpec.describe SchemesController, type: :request do let(:setup_schemes) { nil } before do - Timecop.freeze(Time.utc(2022, 10, 10)) + Timecop.freeze(Time.utc(2023, 10, 10)) sign_in user setup_schemes patch "/schemes/#{scheme.id}/new-deactivation", params: