Browse Source

CLDC-3264: Setup to allow using future form on staging for testing (#2279)

* CLDC-3264: Setup to allow using future form on staging for testing

* Update bulk upload year_spec tests

* Fix indentation

* Disable future form use on review apps for testing

* Move lettings startdate 14 day validation to enforce order

* Update tests

* Restore future form use on review apps
pull/2289/head
Rachael Booth 11 months ago committed by GitHub
parent
commit
642b9cdaf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/controllers/bulk_upload_lettings_logs_controller.rb
  2. 8
      app/controllers/bulk_upload_sales_logs_controller.rb
  3. 12
      app/models/form_handler.rb
  4. 6
      app/models/forms/bulk_upload_lettings/prepare_your_file.rb
  5. 5
      app/models/forms/bulk_upload_lettings/year.rb
  6. 6
      app/models/forms/bulk_upload_sales/prepare_your_file.rb
  7. 6
      app/models/forms/bulk_upload_sales/year.rb
  8. 4
      app/models/validations/date_validations.rb
  9. 4
      app/models/validations/sales/setup_validations.rb
  10. 6
      app/models/validations/setup_validations.rb
  11. 21
      app/services/feature_toggle.rb
  12. 122
      spec/features/bulk_upload_lettings_logs_spec.rb
  13. 90
      spec/features/bulk_upload_sales_logs_spec.rb
  14. 47
      spec/models/forms/bulk_upload_lettings/year_spec.rb
  15. 51
      spec/models/forms/bulk_upload_sales/year_spec.rb
  16. 13
      spec/models/validations/date_validations_spec.rb
  17. 22
      spec/models/validations/setup_validations_spec.rb

6
app/controllers/bulk_upload_lettings_logs_controller.rb

@ -3,7 +3,7 @@ class BulkUploadLettingsLogsController < ApplicationController
before_action :validate_data_protection_agrement_signed! before_action :validate_data_protection_agrement_signed!
def start def start
if in_crossover_period? if have_choice_of_year?
redirect_to bulk_upload_lettings_log_path(id: "year") redirect_to bulk_upload_lettings_log_path(id: "year")
else else
redirect_to bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: current_year }) redirect_to bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: current_year })
@ -34,8 +34,8 @@ private
FormHandler.instance.current_collection_start_year FormHandler.instance.current_collection_start_year
end end
def in_crossover_period? def have_choice_of_year?
return true if FeatureToggle.force_crossover? return true if FeatureToggle.allow_future_form_use?
FormHandler.instance.lettings_in_crossover_period? FormHandler.instance.lettings_in_crossover_period?
end end

8
app/controllers/bulk_upload_sales_logs_controller.rb

@ -3,7 +3,7 @@ class BulkUploadSalesLogsController < ApplicationController
before_action :validate_data_protection_agrement_signed! before_action :validate_data_protection_agrement_signed!
def start def start
if in_crossover_period? if have_choice_of_year?
redirect_to bulk_upload_sales_log_path(id: "year") redirect_to bulk_upload_sales_log_path(id: "year")
else else
redirect_to bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: current_year }) redirect_to bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: current_year })
@ -31,11 +31,11 @@ private
end end
def current_year def current_year
FormHandler.instance.forms["current_sales"].start_date.year FormHandler.instance.current_collection_start_year
end end
def in_crossover_period? def have_choice_of_year?
return true if FeatureToggle.force_crossover? return true if FeatureToggle.allow_future_form_use?
FormHandler.instance.sales_in_crossover_period? FormHandler.instance.sales_in_crossover_period?
end end

12
app/models/form_handler.rb

@ -32,10 +32,22 @@ class FormHandler
forms["previous_lettings"] forms["previous_lettings"]
end end
def next_lettings_form
forms["next_lettings"]
end
def current_sales_form def current_sales_form
forms["current_sales"] forms["current_sales"]
end end
def previous_sales_form
forms["previous_sales"]
end
def next_sales_form
forms["next_sales"]
end
def sales_forms def sales_forms
@sales_forms ||= { @sales_forms ||= {
"current_sales" => Form.new(nil, current_collection_start_year, SALES_SECTIONS, "sales"), "current_sales" => Form.new(nil, current_collection_start_year, SALES_SECTIONS, "sales"),

6
app/models/forms/bulk_upload_lettings/prepare_your_file.rb

@ -18,7 +18,7 @@ module Forms
end end
def back_path def back_path
if in_crossover_period? if have_choice_of_year?
Rails.application.routes.url_helpers.bulk_upload_lettings_log_path(id: "year", form: { year: }) Rails.application.routes.url_helpers.bulk_upload_lettings_log_path(id: "year", form: { year: })
else else
Rails.application.routes.url_helpers.lettings_logs_path Rails.application.routes.url_helpers.lettings_logs_path
@ -65,8 +65,8 @@ module Forms
private private
def in_crossover_period? def have_choice_of_year?
return true if FeatureToggle.force_crossover? return true if FeatureToggle.allow_future_form_use?
FormHandler.instance.lettings_in_crossover_period? FormHandler.instance.lettings_in_crossover_period?
end end

5
app/models/forms/bulk_upload_lettings/year.rb

@ -36,8 +36,9 @@ module Forms
def possible_years def possible_years
[ [
FormHandler.instance.lettings_forms["current_lettings"].start_date.year, FormHandler.instance.lettings_forms["current_lettings"].start_date.year,
FormHandler.instance.lettings_forms["previous_lettings"].start_date.year, (FormHandler.instance.previous_lettings_form.start_date.year if FormHandler.instance.lettings_in_crossover_period?),
] (FormHandler.instance.next_lettings_form.start_date.year if FeatureToggle.allow_future_form_use?),
].compact
end end
end end
end end

6
app/models/forms/bulk_upload_sales/prepare_your_file.rb

@ -17,7 +17,7 @@ module Forms
end end
def back_path def back_path
if in_crossover_period? if have_choice_of_year?
Rails.application.routes.url_helpers.bulk_upload_sales_log_path(id: "year", form: { year: }) Rails.application.routes.url_helpers.bulk_upload_sales_log_path(id: "year", form: { year: })
else else
Rails.application.routes.url_helpers.sales_logs_path Rails.application.routes.url_helpers.sales_logs_path
@ -63,8 +63,8 @@ module Forms
private private
def in_crossover_period? def have_choice_of_year?
return true if FeatureToggle.force_crossover? return true if FeatureToggle.allow_future_form_use?
FormHandler.instance.sales_in_crossover_period? FormHandler.instance.sales_in_crossover_period?
end end

6
app/models/forms/bulk_upload_sales/year.rb

@ -34,7 +34,11 @@ module Forms
private private
def possible_years def possible_years
[FormHandler.instance.sales_forms["current_sales"].start_date.year, FormHandler.instance.sales_forms["previous_sales"].start_date.year] [
FormHandler.instance.current_sales_form.start_date.year,
(FormHandler.instance.previous_sales_form.start_date.year if FormHandler.instance.sales_in_crossover_period?),
(FormHandler.instance.next_sales_form.start_date.year if FeatureToggle.allow_future_form_use?),
].compact
end end
end end
end end

4
app/models/validations/date_validations.rb

@ -34,10 +34,6 @@ module Validations::DateValidations
def validate_startdate(record) def validate_startdate(record)
return unless record.startdate && date_valid?("startdate", record) return unless record.startdate && date_valid?("startdate", record)
if FeatureToggle.startdate_two_week_validation_enabled? && record.startdate > Time.zone.today + 14.days
record.errors.add :startdate, I18n.t("validations.setup.startdate.later_than_14_days_after")
end
if record["voiddate"].present? && record.startdate < record["voiddate"] if record["voiddate"].present? && record.startdate < record["voiddate"]
record.errors.add :startdate, I18n.t("validations.setup.startdate.after_void_date") record.errors.add :startdate, I18n.t("validations.setup.startdate.after_void_date")
end end

4
app/models/validations/sales/setup_validations.rb

@ -3,7 +3,7 @@ module Validations::Sales::SetupValidations
include CollectionTimeHelper include CollectionTimeHelper
def validate_saledate_collection_year(record) def validate_saledate_collection_year(record)
return unless record.saledate && date_valid?("saledate", record) && FeatureToggle.saledate_collection_window_validation_enabled? return unless record.saledate && date_valid?("saledate", record) && !FeatureToggle.allow_future_form_use?
first_collection_start_date = if record.saledate_was.present? first_collection_start_date = if record.saledate_was.present?
editable_collection_start_date editable_collection_start_date
@ -17,7 +17,7 @@ module Validations::Sales::SetupValidations
end end
def validate_saledate_two_weeks(record) def validate_saledate_two_weeks(record)
return unless record.saledate && date_valid?("saledate", record) && FeatureToggle.saledate_two_week_validation_enabled? return unless record.saledate && date_valid?("saledate", record) && !FeatureToggle.allow_future_form_use?
if record.saledate > Time.zone.today + 14.days if record.saledate > Time.zone.today + 14.days
record.errors.add :saledate, I18n.t("validations.setup.saledate.later_than_14_days_after") record.errors.add :saledate, I18n.t("validations.setup.saledate.later_than_14_days_after")

6
app/models/validations/setup_validations.rb

@ -3,7 +3,7 @@ module Validations::SetupValidations
include CollectionTimeHelper include CollectionTimeHelper
def validate_startdate_setup(record) def validate_startdate_setup(record)
return unless record.startdate && date_valid?("startdate", record) && FeatureToggle.startdate_collection_window_validation_enabled? return unless record.startdate && date_valid?("startdate", record) && !FeatureToggle.allow_future_form_use?
first_collection_start_date = if record.startdate_was.present? first_collection_start_date = if record.startdate_was.present?
editable_collection_start_date editable_collection_start_date
@ -14,6 +14,10 @@ module Validations::SetupValidations
unless record.startdate.between?(first_collection_start_date, current_collection_end_date) unless record.startdate.between?(first_collection_start_date, current_collection_end_date)
record.errors.add :startdate, startdate_validation_error_message record.errors.add :startdate, startdate_validation_error_message
end end
if record.startdate > Time.zone.today + 14.days
record.errors.add :startdate, I18n.t("validations.setup.startdate.later_than_14_days_after")
end
end end
def validate_organisation(record) def validate_organisation(record)

21
app/services/feature_toggle.rb

@ -1,19 +1,6 @@
class FeatureToggle class FeatureToggle
# Disable check on preview apps to allow for testing of future forms def self.allow_future_form_use?
def self.saledate_collection_window_validation_enabled? Rails.env.development? || Rails.env.review? || Rails.env.staging?
Rails.env.production? || Rails.env.test? || Rails.env.staging?
end
def self.startdate_collection_window_validation_enabled?
Rails.env.production? || Rails.env.test? || Rails.env.staging?
end
def self.startdate_two_week_validation_enabled?
Rails.env.production? || Rails.env.test? || Rails.env.staging?
end
def self.saledate_two_week_validation_enabled?
Rails.env.production? || Rails.env.test? || Rails.env.staging?
end end
def self.bulk_upload_duplicate_log_check_enabled? def self.bulk_upload_duplicate_log_check_enabled?
@ -24,10 +11,6 @@ class FeatureToggle
!Rails.env.development? !Rails.env.development?
end end
def self.force_crossover?
false
end
def self.deduplication_flow_enabled? def self.deduplication_flow_enabled?
true true
end end

122
spec/features/bulk_upload_lettings_logs_spec.rb

@ -22,94 +22,108 @@ RSpec.describe "Bulk upload lettings log" do
# rubocop:disable RSpec/AnyInstance # rubocop:disable RSpec/AnyInstance
context "when during crossover period" do context "when during crossover period" do
before do before do
allow(FeatureToggle).to receive(:force_crossover?).and_return(true) Timecop.freeze(2023, 6, 1)
end
after do
Timecop.return
end end
it "shows journey with year option" do it "shows journey with year option" do
Timecop.freeze(2023, 6, 1) do visit("/lettings-logs")
visit("/lettings-logs") expect(page).to have_link("Upload lettings logs in bulk")
expect(page).to have_link("Upload lettings logs in bulk") click_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk")
expect(page).to have_content("Which year") expect(page).to have_content("Which year")
click_button("Continue") click_button("Continue")
expect(page).to have_content("You must select a collection period to upload for") expect(page).to have_content("You must select a collection period to upload for")
choose("2023/2024") choose("2023/2024")
click_button("Continue") click_button("Continue")
click_link("Back") click_link("Back")
expect(page.find_field("form-year-2023-field")).to be_checked expect(page.find_field("form-year-2023-field")).to be_checked
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload lettings logs in bulk (2023/24)") expect(page).to have_content("Upload lettings logs in bulk (2023/24)")
click_button("Continue") click_button("Continue")
expect(page).not_to have_content("What is the needs type?") expect(page).not_to have_content("What is the needs type?")
expect(page).to have_content("Upload lettings logs in bulk (2023/24)") expect(page).to have_content("Upload lettings logs in bulk (2023/24)")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")
click_button("Upload") click_button("Upload")
allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("not a csv") allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("not a csv")
expect(page).to have_content("Select which file to upload") expect(page).to have_content("Select which file to upload")
attach_file "file", file_fixture("2023_24_lettings_bulk_upload.xlsx") attach_file "file", file_fixture("2023_24_lettings_bulk_upload.xlsx")
click_button("Upload") click_button("Upload")
allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("text/csv") allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("text/csv")
expect(page).to have_content("Your file must be in CSV format") expect(page).to have_content("Your file must be in CSV format")
attach_file "file", file_fixture("blank_bulk_upload_sales.csv") attach_file "file", file_fixture("blank_bulk_upload_sales.csv")
expect { expect {
click_button("Upload") click_button("Upload")
}.to change(BulkUpload, :count).by(1) }.to change(BulkUpload, :count).by(1)
expect(page).to have_content("Once this is done") expect(page).to have_content("Once this is done")
click_link("Back") click_link("Back")
expect(page).to have_content("Upload lettings logs in bulk") expect(page).to have_content("Upload lettings logs in bulk")
end
end end
end end
# rubocop:enable RSpec/AnyInstance # rubocop:enable RSpec/AnyInstance
context "when not it crossover period" do context "when not it crossover period" do
before do
Timecop.freeze(2024, 1, 1)
end
after do
Timecop.return
end
it "shows journey with year option" do it "shows journey with year option" do
Timecop.freeze(2024, 1, 1) do visit("/lettings-logs")
visit("/lettings-logs") expect(page).to have_link("Upload lettings logs in bulk")
expect(page).to have_link("Upload lettings logs in bulk") click_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk")
expect(page).to have_content("Upload lettings logs in bulk (2023/24)") expect(page).to have_content("Upload lettings logs in bulk (2023/24)")
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")
end
end end
end end
context "when the collection year isn't 22/23" do context "when the collection year isn't 22/23" do
before do
Timecop.freeze(2024, 1, 1)
end
after do
Timecop.return
end
it "shows journey without the needstype" do it "shows journey without the needstype" do
Timecop.freeze(2024, 1, 1) do visit("/lettings-logs")
visit("/lettings-logs") expect(page).to have_link("Upload lettings logs in bulk")
expect(page).to have_link("Upload lettings logs in bulk") click_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk")
expect(page).to have_content("Prepare your file") expect(page).to have_content("Prepare your file")
click_button("Continue") click_button("Continue")
click_link("Back") click_link("Back")
expect(page).to have_content("Prepare your file") expect(page).to have_content("Prepare your file")
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload lettings logs in bulk (2023/24)") expect(page).to have_content("Upload lettings logs in bulk (2023/24)")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")
click_button("Upload") click_button("Upload")
end
end end
end end
end end

90
spec/features/bulk_upload_sales_logs_spec.rb

@ -22,68 +22,76 @@ RSpec.describe "Bulk upload sales log" do
# rubocop:disable RSpec/AnyInstance # rubocop:disable RSpec/AnyInstance
context "when during crossover period" do context "when during crossover period" do
before do before do
allow(FeatureToggle).to receive(:force_crossover?).and_return(true) Timecop.freeze(2023, 5, 1)
end
after do
Timecop.return
end end
it "shows journey with year option" do it "shows journey with year option" do
Timecop.freeze(2023, 5, 1) do visit("/sales-logs")
visit("/sales-logs") expect(page).to have_link("Upload sales logs in bulk")
expect(page).to have_link("Upload sales logs in bulk") click_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk")
expect(page).to have_content("Which year") expect(page).to have_content("Which year")
click_button("Continue") click_button("Continue")
expect(page).to have_content("You must select a collection period to upload for") expect(page).to have_content("You must select a collection period to upload for")
choose("2023/2024") choose("2023/2024")
click_button("Continue") click_button("Continue")
click_link("Back") click_link("Back")
expect(page.find_field("form-year-2023-field")).to be_checked expect(page.find_field("form-year-2023-field")).to be_checked
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload sales logs in bulk (2023/24)") expect(page).to have_content("Upload sales logs in bulk (2023/24)")
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")
click_button("Upload") click_button("Upload")
allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("not a csv") allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("not a csv")
expect(page).to have_content("Select which file to upload") expect(page).to have_content("Select which file to upload")
attach_file "file", file_fixture("2023_24_lettings_bulk_upload.xlsx") attach_file "file", file_fixture("2023_24_lettings_bulk_upload.xlsx")
click_button("Upload") click_button("Upload")
allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("text/csv") allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("text/csv")
expect(page).to have_content("Your file must be in CSV format") expect(page).to have_content("Your file must be in CSV format")
attach_file "file", file_fixture("blank_bulk_upload_sales.csv") attach_file "file", file_fixture("blank_bulk_upload_sales.csv")
expect { expect {
click_button("Upload") click_button("Upload")
}.to change(BulkUpload, :count).by(1) }.to change(BulkUpload, :count).by(1)
expect(page).to have_content("Once this is done") expect(page).to have_content("Once this is done")
click_link("Back") click_link("Back")
expect(page).to have_content("Upload sales logs in bulk") expect(page).to have_content("Upload sales logs in bulk")
end
end end
end end
# rubocop:enable RSpec/AnyInstance # rubocop:enable RSpec/AnyInstance
context "when not it crossover period" do context "when not in crossover period" do
xit "shows journey with year option" do before do
Timecop.freeze(2023, 10, 1) do Timecop.freeze(2024, 2, 1)
visit("/sales-logs") end
expect(page).to have_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk") after do
Timecop.return
end
it "shows journey without year option" do
visit("/sales-logs")
expect(page).to have_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk")
expect(page).to have_content("Upload sales logs in bulk (2023/24)") expect(page).to have_content("Upload sales logs in bulk (2023/24)")
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")
end
end end
end end
end end

47
spec/models/forms/bulk_upload_lettings/year_spec.rb

@ -4,9 +4,50 @@ RSpec.describe Forms::BulkUploadLettings::Year do
subject(:form) { described_class.new } subject(:form) { described_class.new }
describe "#options" do describe "#options" do
it "returns correct years" do context "when in a crossover period" do
expect(form.options.map(&:id)).to eql([2023, 2022]) before do
expect(form.options.map(&:name)).to eql(%w[2023/2024 2022/2023]) Timecop.freeze(2024, 4, 1)
end
after do
Timecop.return
end
it "returns current and previous years" do
expect(form.options.map(&:id)).to eql([2024, 2023])
expect(form.options.map(&:name)).to eql(%w[2024/2025 2023/2024])
end
end
context "when not in a crossover period" do
before do
Timecop.freeze(2024, 3, 1)
end
after do
Timecop.return
end
it "returns the current year" do
expect(form.options.map(&:id)).to eql([2023])
expect(form.options.map(&:name)).to eql(%w[2023/2024])
end
end
context "when allow_future_form_use is toggled on" do
before do
Timecop.freeze(2024, 3, 1)
allow(FeatureToggle).to receive(:allow_future_form_use?).and_return(true)
end
after do
Timecop.return
end
it "returns current and next years" do
expect(form.options.map(&:id)).to eql([2023, 2024])
expect(form.options.map(&:name)).to eql(%w[2023/2024 2024/2025])
end
end end
end end
end end

51
spec/models/forms/bulk_upload_sales/year_spec.rb

@ -3,16 +3,51 @@ require "rails_helper"
RSpec.describe Forms::BulkUploadSales::Year do RSpec.describe Forms::BulkUploadSales::Year do
subject(:form) { described_class.new } subject(:form) { described_class.new }
around do |example| describe "#options" do
Timecop.freeze(Time.zone.now) do context "when in a crossover period" do
example.run before do
Timecop.freeze(2024, 4, 1)
end
after do
Timecop.return
end
it "returns current and previous years" do
expect(form.options.map(&:id)).to eql([2024, 2023])
expect(form.options.map(&:name)).to eql(%w[2024/2025 2023/2024])
end
end end
end
describe "#options" do context "when not in a crossover period" do
it "returns correct years" do before do
expect(form.options.map(&:id)).to eql([2023, 2022]) Timecop.freeze(2024, 3, 1)
expect(form.options.map(&:name)).to eql(%w[2023/2024 2022/2023]) end
after do
Timecop.return
end
it "returns the current year" do
expect(form.options.map(&:id)).to eql([2023])
expect(form.options.map(&:name)).to eql(%w[2023/2024])
end
end
context "when allow_future_form_use is toggled on" do
before do
Timecop.freeze(2024, 3, 1)
allow(FeatureToggle).to receive(:allow_future_form_use?).and_return(true)
end
after do
Timecop.return
end
it "returns current and next years" do
expect(form.options.map(&:id)).to eql([2023, 2024])
expect(form.options.map(&:name)).to eql(%w[2023/2024 2024/2025])
end
end end
end end
end end

13
spec/models/validations/date_validations_spec.rb

@ -59,19 +59,6 @@ RSpec.describe Validations::DateValidations do
date_validator.validate_startdate(record) date_validator.validate_startdate(record)
expect(record.errors["startdate"]).to be_empty expect(record.errors["startdate"]).to be_empty
end end
it "validates that the tenancy start date is not later than 14 days from the current date" do
record.startdate = Time.zone.today + 15.days
date_validator.validate_startdate(record)
expect(record.errors["startdate"])
.to include(match I18n.t("validations.setup.startdate.later_than_14_days_after"))
end
it "produces no error when tenancy start date is not later than 14 days from the current date" do
record.startdate = Time.zone.today + 7.days
date_validator.validate_startdate(record)
expect(record.errors["startdate"]).to be_empty
end
end end
describe "major repairs date" do describe "major repairs date" do

22
spec/models/validations/setup_validations_spec.rb

@ -141,6 +141,28 @@ RSpec.describe Validations::SetupValidations do
end end
end end
context "when attempted startdate is more than 14 days from the current date" do
before do
Timecop.freeze(2024, 3, 1)
end
it "adds an error to startdate" do
record.startdate = Time.zone.local(2024, 3, 31)
setup_validator.validate_startdate_setup(record)
expect(record.errors["startdate"]).to include(match I18n.t("validations.setup.startdate.later_than_14_days_after"))
end
context "and the attempted startdate is in a future collection year" do
it "adds both errors to startdate, with the collection year error first" do
record.startdate = Time.zone.local(2024, 4, 1)
setup_validator.validate_startdate_setup(record)
expect(record.errors["startdate"].length).to be >= 2
expect(record.errors["startdate"][0]).to eq("Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")
expect(record.errors["startdate"][1]).to eq(I18n.t("validations.setup.startdate.later_than_14_days_after"))
end
end
end
context "when organisations were merged" do context "when organisations were merged" do
around do |example| around do |example|
Timecop.freeze(Time.zone.local(2023, 5, 1)) Timecop.freeze(Time.zone.local(2023, 5, 1))

Loading…
Cancel
Save