Browse Source

Make full stops consistent in error messages

pull/2628/head
Manny Dinssa 2 years ago committed by Kat
parent
commit
866435c5ec
  1. 2
      app/services/bulk_upload/sales/year2024/row_parser.rb
  2. 715
      config/locales/en.yml
  3. 2
      spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb
  4. 6
      spec/models/form/lettings/questions/declaration_spec.rb
  5. 2
      spec/models/form/lettings/questions/offered_spec.rb
  6. 2
      spec/models/form/lettings/questions/uprn_spec.rb
  7. 4
      spec/models/form/sales/questions/prevown_spec.rb
  8. 12
      spec/models/form/sales/questions/privacy_notice_spec.rb
  9. 4
      spec/models/form/sales/questions/staircase_owned_spec.rb
  10. 2
      spec/models/form/sales/questions/uprn_spec.rb
  11. 2
      spec/models/location_deactivation_period_spec.rb
  12. 4
      spec/models/scheme_deactivation_period_spec.rb
  13. 46
      spec/models/validations/financial_validations_spec.rb
  14. 4
      spec/models/validations/household_validations_spec.rb
  15. 4
      spec/models/validations/property_validations_spec.rb
  16. 12
      spec/models/validations/sales/financial_validations_spec.rb
  17. 8
      spec/models/validations/sales/household_validations_spec.rb
  18. 20
      spec/models/validations/sales/property_validations_spec.rb
  19. 8
      spec/models/validations/sales/sale_information_validations_spec.rb
  20. 2
      spec/models/validations/sales/setup_validations_spec.rb
  21. 2
      spec/models/validations/setup_validations_spec.rb
  22. 2
      spec/requests/lettings_logs_controller_spec.rb
  23. 2
      spec/requests/sales_logs_controller_spec.rb
  24. 6
      spec/services/bulk_upload/lettings/validator_spec.rb
  25. 28
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  26. 34
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  27. 2
      spec/services/bulk_upload/sales/validator_spec.rb
  28. 2
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
  29. 20
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

2
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -1457,7 +1457,7 @@ private
field_mapping_for_errors[interruption_screen_question_id.to_sym]&.each do |field| field_mapping_for_errors[interruption_screen_question_id.to_sym]&.each do |field|
if errors.none? { |e| e.options[:category] == :soft_validation && field_mapping_for_errors[interruption_screen_question_id.to_sym].include?(e.attribute) } if errors.none? { |e| e.options[:category] == :soft_validation && field_mapping_for_errors[interruption_screen_question_id.to_sym].include?(e.attribute) }
error_message = [display_title_text(question.page.title_text, log), display_informative_text(question.page.informative_text, log)].reject(&:empty?).join(". ") error_message = [display_title_text(question.page.title_text, log), display_informative_text(question.page.informative_text, log)].reject(&:empty?).join(" ")
errors.add(field, message: error_message, category: :soft_validation) errors.add(field, message: error_message, category: :soft_validation)
end end
end end

715
config/locales/en.yml

File diff suppressed because it is too large Load Diff

2
spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

@ -445,7 +445,7 @@ RSpec.describe "bulk_update" do
expect(Rails.logger).to receive(:info).with("Will not export log #{lettings_log_5.id} as it is before the exportable date") expect(Rails.logger).to receive(:info).with("Will not export log #{lettings_log_5.id} as it is before the exportable date")
expect(Rails.logger).to receive(:info).with("No changes to location #{locations[1].id}.") expect(Rails.logger).to receive(:info).with("No changes to location #{locations[1].id}.")
expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with postcode: SWAAA. Enter a postcode in the correct format, for example AA1 1AA") expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with postcode: SWAAA. Enter a postcode in the correct format, for example AA1 1AA.")
expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with scheme_code: S. Scheme with id S is not in the database") expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with scheme_code: S. Scheme with id S is not in the database")
expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with location_admin_district: Westminst. Location admin distrint Westminst is not a valid option") expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with location_admin_district: Westminst. Location admin distrint Westminst is not a valid option")
expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with type_of_unit: elf-contained house. 'elf-contained house' is not a valid type_of_unit") expect(Rails.logger).to receive(:info).with("Cannot update location #{locations[2].id} with type_of_unit: elf-contained house. 'elf-contained house' is not a valid type_of_unit")

6
spec/models/form/lettings/questions/declaration_spec.rb

@ -50,7 +50,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"declaration" => { "value" => "The tenant has seen the MHCLG privacy notice" }, "declaration" => { "value" => "The tenant has seen the MHCLG privacy notice." },
}) })
end end
@ -63,7 +63,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
end end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the tenant before you can submit this log") expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the tenant before you can submit this log.")
end end
end end
@ -87,7 +87,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
end end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show or give the tenant access to the MHCLG privacy notice before you can submit this log") expect(question.unanswered_error_message).to eq("You must show or give the tenant access to the MHCLG privacy notice before you can submit this log.")
end end
end end
end end

2
spec/models/form/lettings/questions/offered_spec.rb

@ -18,7 +18,7 @@ RSpec.describe Form::Lettings::Questions::Offered, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq "Times previously offered since becoming available" expect(question.check_answer_label).to eq "Times previously offered since becoming available."
end end
it "has the correct type" do it "has the correct type" do

2
spec/models/form/lettings/questions/uprn_spec.rb

@ -40,7 +40,7 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
end end
it "has the correct unanswered_error_message" do it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("UPRN must be 12 digits or less") expect(question.unanswered_error_message).to eq("UPRN must be 12 digits or less.")
end end
describe "get_extra_check_answer_value" do describe "get_extra_check_answer_value" do

4
spec/models/form/sales/questions/prevown_spec.rb

@ -22,7 +22,7 @@ RSpec.describe Form::Sales::Questions::Prevown, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer previously owned a property") expect(question.check_answer_label).to eq("Buyer previously owned a property.")
end end
end end
@ -34,7 +34,7 @@ RSpec.describe Form::Sales::Questions::Prevown, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyers previously owned a property") expect(question.check_answer_label).to eq("Buyers previously owned a property.")
end end
end end

12
spec/models/form/sales/questions/privacy_notice_spec.rb

@ -60,7 +60,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyer before you can submit this log") expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyer before you can submit this log.")
end end
end end
@ -78,7 +78,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyers before you can submit this log") expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyers before you can submit this log.")
end end
end end
end end
@ -91,7 +91,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
context "and there is a single buyer" do context "and there is a single buyer" do
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyer has seen or been given access to the MHCLG privacy notice" }, "privacynotice" => { "value" => "The buyer has seen or been given access to the MHCLG privacy notice." },
}) })
end end
@ -100,7 +100,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show or give the buyer access to the MHCLG privacy notice before you can submit this log") expect(question.unanswered_error_message).to eq("You must show or give the buyer access to the MHCLG privacy notice before you can submit this log.")
end end
end end
@ -109,7 +109,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"privacynotice" => { "value" => "The buyers have seen or been given access to the MHCLG privacy notice" }, "privacynotice" => { "value" => "The buyers have seen or been given access to the MHCLG privacy notice." },
}) })
end end
@ -118,7 +118,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
it "returns correct unanswered_error_message" do it "returns correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must show or give the buyers access to the MHCLG privacy notice before you can submit this log") expect(question.unanswered_error_message).to eq("You must show or give the buyers access to the MHCLG privacy notice before you can submit this log.")
end end
end end
end end

4
spec/models/form/sales/questions/staircase_owned_spec.rb

@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Percentage the buyers now own in total") expect(question.check_answer_label).to eq("Percentage the buyers now own in total.")
end end
end end
@ -34,7 +34,7 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Percentage the buyer now owns in total") expect(question.check_answer_label).to eq("Percentage the buyer now owns in total.")
end end
end end

2
spec/models/form/sales/questions/uprn_spec.rb

@ -40,7 +40,7 @@ RSpec.describe Form::Sales::Questions::Uprn, type: :model do
end end
it "has the correct unanswered_error_message" do it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("UPRN must be 12 digits or less") expect(question.unanswered_error_message).to eq("UPRN must be 12 digits or less.")
end end
describe "get_extra_check_answer_value" do describe "get_extra_check_answer_value" do

2
spec/models/location_deactivation_period_spec.rb

@ -80,7 +80,7 @@ RSpec.describe LocationDeactivationPeriod do
location.location_deactivation_periods.clear location.location_deactivation_periods.clear
validator.validate(record) validator.validate(record)
start_date = startdate.to_formatted_s(:govuk_date) start_date = startdate.to_formatted_s(:govuk_date)
expect(record.errors[:deactivation_date]).to include "The location cannot be deactivated before #{start_date}, the date when it was first available" expect(record.errors[:deactivation_date]).to include "The location cannot be deactivated before #{start_date}, the date when it was first available."
end end
end end
end end

4
spec/models/scheme_deactivation_period_spec.rb

@ -23,7 +23,7 @@ RSpec.describe SchemeDeactivationPeriod do
record.deactivation_date = current_collection_start_date - 1.year record.deactivation_date = current_collection_start_date - 1.year
scheme.scheme_deactivation_periods.clear scheme.scheme_deactivation_periods.clear
validator.validate(record) validator.validate(record)
expect(record.errors[:deactivation_date]).to include("The date must be on or after the 1 April 2023") expect(record.errors[:deactivation_date]).to include("The date must be on or after the 1 April 2023.")
end end
end end
@ -47,7 +47,7 @@ RSpec.describe SchemeDeactivationPeriod do
record.deactivation_date = previous_collection_start_date - 2.years record.deactivation_date = previous_collection_start_date - 2.years
scheme.scheme_deactivation_periods.clear scheme.scheme_deactivation_periods.clear
validator.validate(record) validator.validate(record)
expect(record.errors[:deactivation_date]).to include("The date must be on or after the 1 April 2022") expect(record.errors[:deactivation_date]).to include("The date must be on or after the 1 April 2022.")
end end
end end

46
spec/models/validations/financial_validations_spec.rb

@ -237,9 +237,9 @@ RSpec.describe Validations::FinancialValidations do
record.ecstat1 = 1 record.ecstat1 = 1
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
expect(record.errors["earnings"]) expect(record.errors["earnings"])
.to eq(["The household’s income cannot be greater than £1,230.00 per week given the household’s working situation"]) .to eq(["The household’s income cannot be greater than £1,230.00 per week given the household’s working situation."])
expect(record.errors["ecstat1"]) expect(record.errors["ecstat1"])
.to eq(["The household’s income of £5,000.00 weekly is too high given the household’s working situation"]) .to eq(["The household’s income of £5,000.00 weekly is too high given the household’s working situation."])
expect(record.errors["hhmemb"]) expect(record.errors["hhmemb"])
.to eq(["The household’s income of £5,000.00 weekly is too high for this number of tenants. Change either the household income or number of tenants."]) .to eq(["The household’s income of £5,000.00 weekly is too high for this number of tenants. Change either the household income or number of tenants."])
end end
@ -254,9 +254,9 @@ RSpec.describe Validations::FinancialValidations do
record.ecstat1 = 1 record.ecstat1 = 1
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
expect(record.errors["earnings"]) expect(record.errors["earnings"])
.to eq(["The household’s income cannot be less than £90.00 per week given the household’s working situation"]) .to eq(["The household’s income cannot be less than £90.00 per week given the household’s working situation."])
expect(record.errors["ecstat1"]) expect(record.errors["ecstat1"])
.to eq(["The household’s income of £50.00 weekly is too low given the household’s working situation"]) .to eq(["The household’s income of £50.00 weekly is too low given the household’s working situation."])
expect(record.errors["hhmemb"]) expect(record.errors["hhmemb"])
.to eq(["The household’s income of £50.00 weekly is too low for this number of tenants. Change either the household income or number of tenants."]) .to eq(["The household’s income of £50.00 weekly is too low for this number of tenants. Change either the household income or number of tenants."])
end end
@ -286,7 +286,7 @@ RSpec.describe Validations::FinancialValidations do
record.ecstat3 = 9 record.ecstat3 = 9
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
expect(record.errors["earnings"]) expect(record.errors["earnings"])
.to eq(["The household’s income cannot be less than £150.00 per week given the household’s working situation"]) .to eq(["The household’s income cannot be less than £150.00 per week given the household’s working situation."])
end end
it "adds errors to relevant fields for each tenant when income is too high" do it "adds errors to relevant fields for each tenant when income is too high" do
@ -301,7 +301,7 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
(1..record.hhmemb).each do |n| (1..record.hhmemb).each do |n|
expect(record.errors["ecstat#{n}"]) expect(record.errors["ecstat#{n}"])
.to eq(["The household’s income of £5,000.00 weekly is too high given the household’s working situation"]) .to eq(["The household’s income of £5,000.00 weekly is too high given the household’s working situation."])
end end
expect(record.errors["age1"]).to be_empty expect(record.errors["age1"]).to be_empty
expect(record.errors["age2"]).to be_empty expect(record.errors["age2"]).to be_empty
@ -325,7 +325,7 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
(1..record.hhmemb).each do |n| (1..record.hhmemb).each do |n|
expect(record.errors["ecstat#{n}"]) expect(record.errors["ecstat#{n}"])
.to eq(["The household’s income of £50.00 weekly is too low given the household’s working situation"]) .to eq(["The household’s income of £50.00 weekly is too low given the household’s working situation."])
end end
(record.hhmemb + 1..8).each do |n| (record.hhmemb + 1..8).each do |n|
expect(record.errors["ecstat#{n}"]).to be_empty expect(record.errors["ecstat#{n}"]).to be_empty
@ -1121,9 +1121,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 5001 record.chcharge = 5001
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks.")
end end
it "validates charge when period is monthly" do it "validates charge when period is monthly" do
@ -1131,9 +1131,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 21_667 record.chcharge = 21_667
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month.")
end end
it "validates charge when period is every 2 weeks" do it "validates charge when period is every 2 weeks" do
@ -1141,9 +1141,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 12_001 record.chcharge = 12_001
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks.")
end end
it "validates charge when period is every 4 weeks" do it "validates charge when period is every 4 weeks" do
@ -1151,9 +1151,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 24_001 record.chcharge = 24_001
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks.")
end end
end end
@ -1209,9 +1209,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 9 record.chcharge = 9
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks.")
end end
it "validates charge when period is monthly" do it "validates charge when period is monthly" do
@ -1219,9 +1219,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 42 record.chcharge = 42
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month.")
end end
it "validates charge when period is every 2 weeks" do it "validates charge when period is every 2 weeks" do
@ -1229,9 +1229,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 19 record.chcharge = 19
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks.")
end end
it "validates charge when period is every 4 weeks" do it "validates charge when period is every 4 weeks" do
@ -1239,9 +1239,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 39 record.chcharge = 39
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks.")
expect(record.errors["period"]) expect(record.errors["period"])
.to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks.")
end end
end end
end end

4
spec/models/validations/household_validations_spec.rb

@ -763,7 +763,7 @@ RSpec.describe Validations::HouseholdValidations do
it "is invalid" do it "is invalid" do
household_validator.validate_combination_of_housing_needs_responses(record) household_validator.validate_combination_of_housing_needs_responses(record)
error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs"] error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs."]
expect(record.errors["housingneeds"]).to eq(error_message) expect(record.errors["housingneeds"]).to eq(error_message)
expect(record.errors["housingneeds_type"]).to eq(error_message) expect(record.errors["housingneeds_type"]).to eq(error_message)
@ -779,7 +779,7 @@ RSpec.describe Validations::HouseholdValidations do
it "is invalid" do it "is invalid" do
household_validator.validate_combination_of_housing_needs_responses(record) household_validator.validate_combination_of_housing_needs_responses(record)
error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs"] error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs."]
expect(record.errors["housingneeds"]).to eq(error_message) expect(record.errors["housingneeds"]).to eq(error_message)
expect(record.errors["housingneeds_type"]).to eq(error_message) expect(record.errors["housingneeds_type"]).to eq(error_message)

4
spec/models/validations/property_validations_spec.rb

@ -276,7 +276,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do it "adds an error" do
property_validator.validate_uprn(log) property_validator.validate_uprn(log)
expect(log.errors.added?(:uprn, "UPRN must be 12 digits or less")).to be true expect(log.errors.added?(:uprn, "UPRN must be 12 digits or less.")).to be true
end end
end end
@ -285,7 +285,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do it "adds an error" do
property_validator.validate_uprn(log) property_validator.validate_uprn(log)
expect(log.errors.added?(:uprn, "UPRN must be 12 digits or less")).to be true expect(log.errors.added?(:uprn, "UPRN must be 12 digits or less.")).to be true
end end
end end

12
spec/models/validations/sales/financial_validations_spec.rb

@ -187,7 +187,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
record.stairowned = 40 record.stairowned = 40
record.jointpur = 1 record.jointpur = 1
financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record) financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record)
expect(record.errors["stairowned"]).to include("Total percentage buyers now own must be more than percentage bought in this transaction") expect(record.errors["stairowned"]).to include("Total percentage buyers now own must be more than percentage bought in this transaction.")
end end
it "adds an error to stairowned and not stairbought if the percentage bought is more than the percentage owned for non joint purchase" do it "adds an error to stairowned and not stairbought if the percentage bought is more than the percentage owned for non joint purchase" do
@ -195,7 +195,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
record.stairowned = 40 record.stairowned = 40
record.jointpur = 2 record.jointpur = 2
financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record) financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record)
expect(record.errors["stairowned"]).to include("Total percentage buyer now owns must be more than percentage bought in this transaction") expect(record.errors["stairowned"]).to include("Total percentage buyer now owns must be more than percentage bought in this transaction.")
end end
end end
@ -270,8 +270,8 @@ RSpec.describe Validations::Sales::FinancialValidations do
[2, 16, 18, 24].each do |type| [2, 16, 18, 24].each do |type|
record.type = type record.type = type
financial_validator.validate_percentage_bought_at_least_threshold(record) financial_validator.validate_percentage_bought_at_least_threshold(record)
expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 10%"]) expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 10%."])
expect(record.errors["type"]).to eq(["The minimum increase in equity while staircasing is 10% for this shared ownership type"]) expect(record.errors["type"]).to eq(["The minimum increase in equity while staircasing is 10% for this shared ownership type."])
record.errors.clear record.errors.clear
end end
@ -279,8 +279,8 @@ RSpec.describe Validations::Sales::FinancialValidations do
[28, 30, 31, 32].each do |type| [28, 30, 31, 32].each do |type|
record.type = type record.type = type
financial_validator.validate_percentage_bought_at_least_threshold(record) financial_validator.validate_percentage_bought_at_least_threshold(record)
expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 1%"]) expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 1%."])
expect(record.errors["type"]).to eq(["The minimum increase in equity while staircasing is 1% for this shared ownership type"]) expect(record.errors["type"]).to eq(["The minimum increase in equity while staircasing is 1% for this shared ownership type."])
record.errors.clear record.errors.clear
end end
end end

8
spec/models/validations/sales/household_validations_spec.rb

@ -345,8 +345,8 @@ RSpec.describe Validations::Sales::HouseholdValidations do
[3, 4, 5, 6, 7, 9, 0].each do |prevten| [3, 4, 5, 6, 7, 9, 0].each do |prevten|
record.prevten = prevten record.prevten = prevten
household_validator.validate_buyer1_previous_tenure(record) household_validator.validate_buyer1_previous_tenure(record)
expect(record.errors["prevten"]).to include("Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales") expect(record.errors["prevten"]).to include("Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales.")
expect(record.errors["ownershipsch"]).to include("Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales") expect(record.errors["ownershipsch"]).to include("Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales.")
end end
end end
@ -420,7 +420,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do
record.ecstat1 = 9 record.ecstat1 = 9
household_validator.validate_buyer_not_child(record) household_validator.validate_buyer_not_child(record)
expect(record.errors["ecstat1"]) expect(record.errors["ecstat1"])
.to include("Buyer 1 cannot have a working situation of child under 16") .to include("Buyer 1 cannot have a working situation of child under 16.")
end end
it "validates buyer 2 isn't a child" do it "validates buyer 2 isn't a child" do
@ -428,7 +428,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do
record.ecstat2 = 9 record.ecstat2 = 9
household_validator.validate_buyer_not_child(record) household_validator.validate_buyer_not_child(record)
expect(record.errors["ecstat2"]) expect(record.errors["ecstat2"])
.to include("Buyer 2 cannot have a working situation of child under 16") .to include("Buyer 2 cannot have a working situation of child under 16.")
end end
it "allows person 2 to be a child" do it "allows person 2 to be a child" do

20
spec/models/validations/sales/property_validations_spec.rb

@ -51,9 +51,9 @@ RSpec.describe Validations::Sales::PropertyValidations do
record.ppostcode_full = "SW1A 0AA" record.ppostcode_full = "SW1A 0AA"
record.jointpur = 1 record.jointpur = 1
property_validator.validate_postcodes_match_if_discounted_ownership(record) property_validator.validate_postcodes_match_if_discounted_ownership(record)
expect(record.errors["postcode_full"]).to include("Buyers’ last accommodation and discounted ownership postcodes must match") expect(record.errors["postcode_full"]).to include("Buyers’ last accommodation and discounted ownership postcodes must match.")
expect(record.errors["ppostcode_full"]).to include("Buyers’ last accommodation and discounted ownership postcodes must match") expect(record.errors["ppostcode_full"]).to include("Buyers’ last accommodation and discounted ownership postcodes must match.")
expect(record.errors["ownershipsch"]).to include("Buyers’ last accommodation and discounted ownership postcodes must match") expect(record.errors["ownershipsch"]).to include("Buyers’ last accommodation and discounted ownership postcodes must match.")
end end
it "when postcodes do not match an error is added for non joint purchase" do it "when postcodes do not match an error is added for non joint purchase" do
@ -61,9 +61,9 @@ RSpec.describe Validations::Sales::PropertyValidations do
record.ppostcode_full = "SW1A 0AA" record.ppostcode_full = "SW1A 0AA"
record.jointpur = 2 record.jointpur = 2
property_validator.validate_postcodes_match_if_discounted_ownership(record) property_validator.validate_postcodes_match_if_discounted_ownership(record)
expect(record.errors["postcode_full"]).to include("Buyer’s last accommodation and discounted ownership postcodes must match") expect(record.errors["postcode_full"]).to include("Buyer’s last accommodation and discounted ownership postcodes must match.")
expect(record.errors["ppostcode_full"]).to include("Buyer’s last accommodation and discounted ownership postcodes must match") expect(record.errors["ppostcode_full"]).to include("Buyer’s last accommodation and discounted ownership postcodes must match.")
expect(record.errors["ownershipsch"]).to include("Buyer’s last accommodation and discounted ownership postcodes must match") expect(record.errors["ownershipsch"]).to include("Buyer’s last accommodation and discounted ownership postcodes must match.")
end end
it "does not add error for 2024 log" do it "does not add error for 2024 log" do
@ -93,8 +93,8 @@ RSpec.describe Validations::Sales::PropertyValidations do
it "does add an error if it's a bedsit" do it "does add an error if it's a bedsit" do
property_validator.validate_bedsit_number_of_beds(record) property_validator.validate_bedsit_number_of_beds(record)
expect(record.errors.added?(:proptype, "Answer cannot be 'Bedsit' if the property has 2 or more bedrooms")).to be true expect(record.errors.added?(:proptype, "Answer cannot be 'Bedsit' if the property has 2 or more bedrooms.")).to be true
expect(record.errors.added?(:beds, "Number of bedrooms must be 1 if the property is a bedsit")).to be true expect(record.errors.added?(:beds, "Number of bedrooms must be 1 if the property is a bedsit.")).to be true
end end
it "does not add an error if proptype is undefined" do it "does not add an error if proptype is undefined" do
@ -120,7 +120,7 @@ RSpec.describe Validations::Sales::PropertyValidations do
it "adds an error" do it "adds an error" do
property_validator.validate_uprn(record) property_validator.validate_uprn(record)
expect(record.errors.added?(:uprn, "UPRN must be 12 digits or less")).to be true expect(record.errors.added?(:uprn, "UPRN must be 12 digits or less.")).to be true
end end
end end
@ -129,7 +129,7 @@ RSpec.describe Validations::Sales::PropertyValidations do
it "adds an error" do it "adds an error" do
property_validator.validate_uprn(record) property_validator.validate_uprn(record)
expect(record.errors.added?(:uprn, "UPRN must be 12 digits or less")).to be true expect(record.errors.added?(:uprn, "UPRN must be 12 digits or less.")).to be true
end end
end end

8
spec/models/validations/sales/sale_information_validations_spec.rb

@ -147,10 +147,10 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
sale_information_validator.validate_exchange_date(record) sale_information_validator.validate_exchange_date(record)
expect(record.errors[:exdate]).to eq( expect(record.errors[:exdate]).to eq(
["Contract exchange date must be less than 1 year before sale completion date"], ["Contract exchange date must be less than 1 year before sale completion date."],
) )
expect(record.errors[:saledate]).to eq( expect(record.errors[:saledate]).to eq(
["Sale completion date must be less than 1 year after contract exchange date"], ["Sale completion date must be less than 1 year after contract exchange date."],
) )
end end
end end
@ -162,10 +162,10 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
sale_information_validator.validate_exchange_date(record) sale_information_validator.validate_exchange_date(record)
expect(record.errors[:exdate]).to eq( expect(record.errors[:exdate]).to eq(
["Contract exchange date must be before sale completion date"], ["Contract exchange date must be before sale completion date."],
) )
expect(record.errors[:saledate]).to eq( expect(record.errors[:saledate]).to eq(
["Sale completion date must be after contract exchange date"], ["Sale completion date must be after contract exchange date."],
) )
end end
end end

2
spec/models/validations/sales/setup_validations_spec.rb

@ -183,7 +183,7 @@ RSpec.describe Validations::Sales::SetupValidations do
it "adds an error" do it "adds an error" do
setup_validator.validate_saledate_two_weeks(record) setup_validator.validate_saledate_two_weeks(record)
expect(record.errors[:saledate]).to include("Sale completion date must not be later than 14 days from today’s date") expect(record.errors[:saledate]).to include("Sale completion date must not be later than 14 days from today’s date.")
end end
end end
end end

2
spec/models/validations/setup_validations_spec.rb

@ -700,7 +700,7 @@ RSpec.describe Validations::SetupValidations do
record.location = location record.location = location
setup_validator.validate_location(record) setup_validator.validate_location(record)
expect(record.errors["location_id"]) expect(record.errors["location_id"])
.to include("This location is incomplete. Select another location or update this one") .to include("This location is incomplete. Select another location or update this one.")
end end
it "produces no error when location is completes" do it "produces no error when location is completes" do

2
spec/requests/lettings_logs_controller_spec.rb

@ -1570,7 +1570,7 @@ RSpec.describe LettingsLogsController, type: :request do
it "returns an error message" do it "returns an error message" do
json_response = JSON.parse(response.body) json_response = JSON.parse(response.body)
expect(json_response["errors"]).to eq({ "age1" => ["Lead tenant’s age must be between 16 and 120"] }) expect(json_response["errors"]).to eq({ "age1" => ["Lead tenant’s age must be between 16 and 120."] })
end end
end end

2
spec/requests/sales_logs_controller_spec.rb

@ -93,7 +93,7 @@ RSpec.describe SalesLogsController, type: :request do
it "validates sales log parameters" do it "validates sales log parameters" do
json_response = JSON.parse(response.body) json_response = JSON.parse(response.body)
expect(response).to have_http_status(:unprocessable_entity) expect(response).to have_http_status(:unprocessable_entity)
expect(json_response["errors"]).to match_array([["beds", ["Number of bedrooms must be 1 if the property is a bedsit"]], ["proptype", ["Answer cannot be 'Bedsit' if the property has 2 or more bedrooms"]]]) expect(json_response["errors"]).to match_array([["beds", ["Number of bedrooms must be 1 if the property is a bedsit."]], ["proptype", ["Answer cannot be 'Bedsit' if the property has 2 or more bedrooms."]]])
end end
end end
end end

6
spec/services/bulk_upload/lettings/validator_spec.rb

@ -51,7 +51,7 @@ RSpec.describe BulkUpload::Lettings::Validator do
it "is not valid" do it "is not valid" do
expect(validator).not_to be_valid expect(validator).not_to be_valid
expect(validator.errors["base"]).to eql(["Incorrect number of fields, please ensure you have used the correct template"]) expect(validator.errors["base"]).to eql(["Incorrect number of fields, please ensure you have used the correct template."])
end end
end end
@ -68,7 +68,7 @@ RSpec.describe BulkUpload::Lettings::Validator do
it "is not valid" do it "is not valid" do
expect(validator).not_to be_valid expect(validator).not_to be_valid
expect(validator.errors["base"]).to eql(["Incorrect number of fields, please ensure you have used the correct template"]) expect(validator.errors["base"]).to eql(["Incorrect number of fields, please ensure you have used the correct template."])
end end
end end
end end
@ -90,7 +90,7 @@ RSpec.describe BulkUpload::Lettings::Validator do
it "is not valid" do it "is not valid" do
expect(validator).not_to be_valid expect(validator).not_to be_valid
expect(validator.errors["base"]).to eql(["Incorrect start dates, please ensure you have used the correct template"]) expect(validator.errors["base"]).to eql(["Incorrect start dates, please ensure you have used the correct template."])
end end
end end
end end

28
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -686,7 +686,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "cannot be nulled" do it "cannot be nulled" do
parser.valid? parser.valid?
expect(parser.errors[:field_45]).to eq(["You must show the MHCLG privacy notice to the tenant before you can submit this log"]) expect(parser.errors[:field_45]).to eq(["You must show the MHCLG privacy notice to the tenant before you can submit this log."])
end end
end end
end end
@ -1106,8 +1106,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid? parser.valid?
expect(parser.errors[:field_15]).to be_blank expect(parser.errors[:field_15]).to be_blank
expect(parser.errors.where(:field_16).map(&:message)).to eq(["This location is incomplete. Select another location or update this one"]) expect(parser.errors.where(:field_16).map(&:message)).to eq(["This location is incomplete. Select another location or update this one."])
expect(parser.errors.where(:field_17).map(&:message)).to eq(["This location is incomplete. Select another location or update this one"]) expect(parser.errors.where(:field_17).map(&:message)).to eq(["This location is incomplete. Select another location or update this one."])
end end
end end
end end
@ -1480,7 +1480,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "returns an error" do it "returns an error" do
parser.valid? parser.valid?
expect(parser.errors[:field_9]).to include("Tenancy start year must be 2 digits") expect(parser.errors[:field_9]).to include("Tenancy start year must be 2 digits.")
end end
end end
@ -2710,8 +2710,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and b" do it "sets error on housingneeds a and b" do
parser.valid? parser.valid?
expect(parser.errors[:field_83]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_83]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_84]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_84]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_85]).to be_blank expect(parser.errors[:field_85]).to be_blank
end end
end end
@ -2721,8 +2721,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and c" do it "sets error on housingneeds a and c" do
parser.valid? parser.valid?
expect(parser.errors[:field_83]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_83]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_85]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_85]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_84]).to be_blank expect(parser.errors[:field_84]).to be_blank
end end
end end
@ -2732,8 +2732,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds b and c" do it "sets error on housingneeds b and c" do
parser.valid? parser.valid?
expect(parser.errors[:field_84]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_84]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_85]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_85]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_83]).to be_blank expect(parser.errors[:field_83]).to be_blank
end end
end end
@ -2743,8 +2743,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and g" do it "sets error on housingneeds a and g" do
parser.valid? parser.valid?
expect(parser.errors[:field_87]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_87]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_83]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_83]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_84]).to be_blank expect(parser.errors[:field_84]).to be_blank
expect(parser.errors[:field_85]).to be_blank expect(parser.errors[:field_85]).to be_blank
end end
@ -2767,8 +2767,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and h" do it "sets error on housingneeds a and h" do
parser.valid? parser.valid?
expect(parser.errors[:field_88]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_88]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_83]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_83]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_84]).to be_blank expect(parser.errors[:field_84]).to be_blank
expect(parser.errors[:field_85]).to be_blank expect(parser.errors[:field_85]).to be_blank
end end

34
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -747,7 +747,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "cannot be nulled" do it "cannot be nulled" do
parser.valid? parser.valid?
expect(parser.errors[:field_15]).to eq(["You must show or give the tenant access to the MHCLG privacy notice before you can submit this log"]) expect(parser.errors[:field_15]).to eq(["You must show or give the tenant access to the MHCLG privacy notice before you can submit this log."])
end end
end end
@ -1021,8 +1021,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_2: owning_org.old_visible_id, field_4: "2", field_11: "2", field_5: "S#{scheme.id}", field_6: incomplete_location.id } } let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_2: owning_org.old_visible_id, field_4: "2", field_11: "2", field_5: "S#{scheme.id}", field_6: incomplete_location.id } }
it "returns a setup error for scheme" do it "returns a setup error for scheme" do
expect(parser.errors.where(:field_5).map(&:message)).to eq(["This location is incomplete. Select another location or update this one"]) expect(parser.errors.where(:field_5).map(&:message)).to eq(["This location is incomplete. Select another location or update this one."])
expect(parser.errors.where(:field_6).map(&:message)).to eq(["This location is incomplete. Select another location or update this one"]) expect(parser.errors.where(:field_6).map(&:message)).to eq(["This location is incomplete. Select another location or update this one."])
end end
end end
end end
@ -1297,7 +1297,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "returns an error" do it "returns an error" do
parser.valid? parser.valid?
expect(parser.errors[:field_10]).to include("Tenancy start year must be 2 digits") expect(parser.errors[:field_10]).to include("Tenancy start year must be 2 digits.")
end end
end end
@ -1602,7 +1602,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an appropriate error to the UPRN field" do it "adds an appropriate error to the UPRN field" do
parser.valid? parser.valid?
expect(parser.errors[:field_16]).to eql(["UPRN must be 12 digits or less"]) expect(parser.errors[:field_16]).to eql(["UPRN must be 12 digits or less."])
end end
it "adds errors to missing key address fields" do it "adds errors to missing key address fields" do
@ -1619,7 +1619,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to the UPRN field only" do it "adds an error to the UPRN field only" do
parser.valid? parser.valid?
expect(parser.errors[:field_16]).to eql(["UPRN must be 12 digits or less"]) expect(parser.errors[:field_16]).to eql(["UPRN must be 12 digits or less."])
%i[field_17 field_19 field_21 field_22].each do |field| %i[field_17 field_19 field_21 field_22].each do |field|
expect(parser.errors[field]).to be_empty expect(parser.errors[field]).to be_empty
end end
@ -1844,7 +1844,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to field_45" do it "adds an error to field_45" do
parser.valid? parser.valid?
expect(parser.errors["field_45"]).to include("Select a valid nationality") expect(parser.errors["field_45"]).to include("Select a valid nationality.")
end end
end end
end end
@ -2813,8 +2813,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and b" do it "sets error on housingneeds a and b" do
parser.valid? parser.valid?
expect(parser.errors[:field_79]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_79]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_80]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_80]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_81]).to be_blank expect(parser.errors[:field_81]).to be_blank
end end
end end
@ -2824,8 +2824,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and c" do it "sets error on housingneeds a and c" do
parser.valid? parser.valid?
expect(parser.errors[:field_79]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_79]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_81]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_81]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_80]).to be_blank expect(parser.errors[:field_80]).to be_blank
end end
end end
@ -2835,8 +2835,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds b and c" do it "sets error on housingneeds b and c" do
parser.valid? parser.valid?
expect(parser.errors[:field_80]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_80]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_81]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected") expect(parser.errors[:field_81]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
expect(parser.errors[:field_79]).to be_blank expect(parser.errors[:field_79]).to be_blank
end end
end end
@ -2846,8 +2846,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and g" do it "sets error on housingneeds a and g" do
parser.valid? parser.valid?
expect(parser.errors[:field_83]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_83]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_79]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_79]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_80]).to be_blank expect(parser.errors[:field_80]).to be_blank
expect(parser.errors[:field_81]).to be_blank expect(parser.errors[:field_81]).to be_blank
end end
@ -2870,8 +2870,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and h" do it "sets error on housingneeds a and h" do
parser.valid? parser.valid?
expect(parser.errors[:field_84]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_84]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_79]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs") expect(parser.errors[:field_79]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
expect(parser.errors[:field_80]).to be_blank expect(parser.errors[:field_80]).to be_blank
expect(parser.errors[:field_81]).to be_blank expect(parser.errors[:field_81]).to be_blank
end end

2
spec/services/bulk_upload/sales/validator_spec.rb

@ -54,7 +54,7 @@ RSpec.describe BulkUpload::Sales::Validator do
it "is not valid" do it "is not valid" do
expect(validator).not_to be_valid expect(validator).not_to be_valid
expect(validator.errors["base"]).to eql(["Incorrect sale dates, please ensure you have used the correct template"]) expect(validator.errors["base"]).to eql(["Incorrect sale dates, please ensure you have used the correct template."])
end end
end end

2
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -597,7 +597,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
let(:attributes) { setup_section_params.merge({ bulk_upload:, field_5: "2022" }) } let(:attributes) { setup_section_params.merge({ bulk_upload:, field_5: "2022" }) }
it "returns a setup error" do it "returns a setup error" do
expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to include("Sale completion year must be 2 digits") expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to include("Sale completion year must be 2 digits.")
end end
end end

20
spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

@ -716,7 +716,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns a setup error" do it "returns a setup error" do
parser.valid? parser.valid?
expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include("Sale completion year must be 2 digits") expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include("Sale completion year must be 2 digits.")
end end
end end
@ -986,7 +986,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "adds an appropriate error to the UPRN field" do it "adds an appropriate error to the UPRN field" do
parser.valid? parser.valid?
expect(parser.errors[:field_22]).to eql(["UPRN must be 12 digits or less"]) expect(parser.errors[:field_22]).to eql(["UPRN must be 12 digits or less."])
end end
it "adds errors to missing key address fields" do it "adds errors to missing key address fields" do
@ -1003,7 +1003,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "adds an error to the UPRN field only" do it "adds an error to the UPRN field only" do
parser.valid? parser.valid?
expect(parser.errors[:field_22]).to eql(["UPRN must be 12 digits or less"]) expect(parser.errors[:field_22]).to eql(["UPRN must be 12 digits or less."])
%i[field_23 field_25 field_27 field_28].each do |field| %i[field_23 field_25 field_27 field_28].each do |field|
expect(parser.errors[field]).to be_empty expect(parser.errors[field]).to be_empty
end end
@ -1108,7 +1108,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
context "when the privacy notice is not accepted" do context "when the privacy notice is not accepted" do
it "cannot be nulled" do it "cannot be nulled" do
expect(parser.errors[:field_18]).to eq(["You must show or give the buyer access to the MHCLG privacy notice before you can submit this log"]) expect(parser.errors[:field_18]).to eq(["You must show or give the buyer access to the MHCLG privacy notice before you can submit this log."])
end end
end end
end end
@ -1198,7 +1198,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do it "a custom validation is applied" do
parser.valid? parser.valid?
validation_message = "Buyer 2 cannot have a working situation of child under 16" validation_message = "Buyer 2 cannot have a working situation of child under 16."
expect(parser.errors[:field_42]).to include validation_message expect(parser.errors[:field_42]).to include validation_message
end end
end end
@ -1220,7 +1220,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do it "a custom validation is applied" do
parser.valid? parser.valid?
validation_message = "Buyer 2's age cannot be 16 or over if their working situation is child under 16" validation_message = "Buyer 2's age cannot be 16 or over if their working situation is child under 16."
expect(parser.errors[:field_42]).to include validation_message expect(parser.errors[:field_42]).to include validation_message
expect(parser.errors[:field_38]).to include validation_message expect(parser.errors[:field_38]).to include validation_message
end end
@ -1244,7 +1244,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do it "a custom validation is applied" do
parser.valid? parser.valid?
validation_message = "Buyer 1 cannot have a working situation of child under 16" validation_message = "Buyer 1 cannot have a working situation of child under 16."
expect(parser.errors[:field_35]).to include validation_message expect(parser.errors[:field_35]).to include validation_message
end end
end end
@ -1266,7 +1266,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do it "a custom validation is applied" do
parser.valid? parser.valid?
validation_message = "Buyer 1's age cannot be 16 or over if their working situation is child under 16" validation_message = "Buyer 1's age cannot be 16 or over if their working situation is child under 16."
expect(parser.errors[:field_35]).to include validation_message expect(parser.errors[:field_35]).to include validation_message
expect(parser.errors[:field_31]).to include validation_message expect(parser.errors[:field_31]).to include validation_message
end end
@ -1676,7 +1676,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid? parser.valid?
expect(parser.log.nationality_all).to be(nil) expect(parser.log.nationality_all).to be(nil)
expect(parser.log.nationality_all_group).to be(nil) expect(parser.log.nationality_all_group).to be(nil)
expect(parser.errors["field_34"]).to include("Select a valid nationality") expect(parser.errors["field_34"]).to include("Select a valid nationality.")
end end
end end
end end
@ -1761,7 +1761,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid? parser.valid?
expect(parser.log.nationality_all_buyer2).to be(nil) expect(parser.log.nationality_all_buyer2).to be(nil)
expect(parser.log.nationality_all_buyer2_group).to be(nil) expect(parser.log.nationality_all_buyer2_group).to be(nil)
expect(parser.errors["field_41"]).to include("Select a valid nationality") expect(parser.errors["field_41"]).to include("Select a valid nationality.")
end end
end end
end end

Loading…
Cancel
Save