From dafbac80632e19546600b688214d91c97b283e45 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Thu, 19 Mar 2026 17:53:00 +0000 Subject: [PATCH] CLDC-4325: Use or later in all touched tests --- spec/models/bulk_upload_spec.rb | 28 ++----------------- .../lettings_log_derived_fields_spec.rb | 20 ++++++------- spec/models/sales_log_spec.rb | 6 ++-- .../validations/household_validations_spec.rb | 4 +-- .../validations/property_validations_spec.rb | 4 +-- .../sale_information_validations_spec.rb | 2 +- .../sales/soft_validations_spec.rb | 6 ++-- 7 files changed, 24 insertions(+), 46 deletions(-) diff --git a/spec/models/bulk_upload_spec.rb b/spec/models/bulk_upload_spec.rb index da95546dd..d8359df71 100644 --- a/spec/models/bulk_upload_spec.rb +++ b/spec/models/bulk_upload_spec.rb @@ -43,31 +43,9 @@ RSpec.describe BulkUpload, type: :model do end end - context "when 2026", metadata: { year: 26 } do - let(:startdate) { collection_start_date_for_year(2026) } - let(:saledate) { collection_start_date_for_year(2026) } - - context "with a lettings log bulk upload" do - let(:log) { build(:lettings_log, startdate:, bulk_upload:) } - - it "has the correct number of value checks to be set as confirmed" do - expect(bulk_upload.fields_to_confirm(log)).to match_array %w[rent_value_check void_date_value_check major_repairs_date_value_check pregnancy_value_check retirement_value_check net_income_value_check scharge_value_check pscharge_value_check supcharg_value_check reasonother_value_check tenancyother_value_check working_situation_illness_check] - end - end - - context "with a sales log bulk upload" do - let(:log) { build(:sales_log, saledate:, bulk_upload:) } - - it "has the correct number of value checks to be set as confirmed" do - expect(bulk_upload.fields_to_confirm(log)).to match_array %w[value_value_check monthly_charges_value_check percentage_discount_value_check income1_value_check income2_value_check combined_income_value_check retirement_value_check old_persons_shared_ownership_value_check buyer_livein_value_check wheel_value_check mortgage_value_check savings_value_check deposit_value_check staircase_bought_value_check stairowned_value_check hodate_check shared_ownership_deposit_value_check extrabor_value_check grant_value_check discounted_sale_value_check deposit_and_mortgage_value_check multiple_partners_value_check partner_under_16_value_check] - end - end - end - - # included to ensure we're testing the next collection we're working on before go live - context "when next collection year" do - let(:startdate) { next_collection_start_date } - let(:saledate) { next_collection_start_date } + context "when 2026 or later", metadata: { year: 26 } do + let(:startdate) { collection_start_date_for_year_or_later(2026) } + let(:saledate) { collection_start_date_for_year_or_later(2026) } context "with a lettings log bulk upload" do let(:log) { build(:lettings_log, startdate:, bulk_upload:) } diff --git a/spec/models/lettings_log_derived_fields_spec.rb b/spec/models/lettings_log_derived_fields_spec.rb index 26bfec121..283dbc473 100644 --- a/spec/models/lettings_log_derived_fields_spec.rb +++ b/spec/models/lettings_log_derived_fields_spec.rb @@ -1093,26 +1093,26 @@ RSpec.describe LettingsLog, type: :model do end end - context "when 2026", metadata: { year: 26 } do - let(:startdate) { collection_start_date_for_year(2026) } + context "when 2026 or later", metadata: { year: 26 } do + let(:startdate) { collection_start_date_for_year_or_later(2026) } it "derives waityear offered referral first_time_property_let_as_social_housing rsnvac when renewal" do log.renewal = 1 expect { log.set_derived_fields! } .to change(log, :waityear).to(2) - .and change(log, :offered).to(0) - .and change(log, :referral_register).to(1) - .and change(log, :first_time_property_let_as_social_housing).to(0) - .and change(log, :rsnvac).to(14) + .and change(log, :offered).to(0) + .and change(log, :referral_register).to(1) + .and change(log, :first_time_property_let_as_social_housing).to(0) + .and change(log, :rsnvac).to(14) end it "clears waityear offered referral first_time_property_let_as_social_housing rsnvac when not a renewal" do expect { persisted_renewal_lettings_log.update!(renewal: 0) } .to change(persisted_renewal_lettings_log, :waityear).from(2).to(nil) - .and change(persisted_renewal_lettings_log, :offered).from(0).to(nil) - .and change(persisted_renewal_lettings_log, :referral_register).from(1).to(nil) - .and change(persisted_renewal_lettings_log, :first_time_property_let_as_social_housing).from(0).to(nil) - .and change(persisted_renewal_lettings_log, :rsnvac).from(14).to(nil) + .and change(persisted_renewal_lettings_log, :offered).from(0).to(nil) + .and change(persisted_renewal_lettings_log, :referral_register).from(1).to(nil) + .and change(persisted_renewal_lettings_log, :first_time_property_let_as_social_housing).from(0).to(nil) + .and change(persisted_renewal_lettings_log, :rsnvac).from(14).to(nil) end end diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 046c00b92..bcca7f766 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -712,7 +712,7 @@ RSpec.describe SalesLog, type: :model do ) end - context "when 2025", metadata: { year: 2025 } do + context "when 2025", metadata: { year: 25 } do let(:saledate) { collection_start_date_for_year(2025) } let(:hholdcount) { 4 } @@ -743,8 +743,8 @@ RSpec.describe SalesLog, type: :model do end end - context "when 2026", metadata: { year: 2026 } do - let(:saledate) { collection_start_date_for_year(2026) } + context "when 2026 or later", metadata: { year: 26 } do + let(:saledate) { collection_start_date_for_year_or_later(2026) } let(:hholdcount) { 6 } it "correctly derives and saves hhmemb" do diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 2893669da..689f97abb 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -500,8 +500,8 @@ RSpec.describe Validations::HouseholdValidations do end end - context "when start year is 2026", metadata: { year: 26 } do - let(:startdate) { collection_start_date_for_year(2026) } + context "when start year is 2026 or later", metadata: { year: 26 } do + let(:startdate) { collection_start_date_for_year_or_later(2026) } [ { diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index 583892b11..05b526a17 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -370,8 +370,8 @@ RSpec.describe Validations::PropertyValidations do end end - context "when 2026", metadata: { year: 26 } do - let(:startdate) { collection_start_date_for_year(2026) } + context "when 2026 or later", metadata: { year: 26 } do + let(:startdate) { collection_start_date_for_year_or_later(2026) } context "and the local authority is active for supported housing log" do let(:log) { build(:lettings_log, :completed, startdate:, la: la_ecode_active, needstype: 2) } diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index 11988cbe4..5f54554ac 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -74,7 +74,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do end context "and form year is 2025 or later" do - let(:saledate) { collection_start_date_for_year(2025) } + let(:saledate) { collection_start_date_for_year_or_later(2025) } it "does not add an error" do sale_information_validator.validate_practical_completion_date(record) diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 896a29bec..fa452c2ca 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -409,8 +409,8 @@ RSpec.describe Validations::Sales::SoftValidations do end end - context "and 2026", metadata: { year: 26 } do - let(:saledate) { collection_start_date_for_year(2026) } + context "and 2026 or later", metadata: { year: 26 } do + let(:saledate) { collection_start_date_for_year_or_later(2026) } it "returns false if the deposit and mortgage add up to less than the discounted value" do record.value = 500_000 @@ -423,7 +423,7 @@ RSpec.describe Validations::Sales::SoftValidations do end context "when validating extra borrowing" do - let(:saledate) { collection_start_date_for_year(2025) } + let(:saledate) { collection_start_date_for_year_or_later(2025) } it "returns false for logs from 2024 onwards" do record.extrabor = 2