Browse Source

CLDC-4325: Use or later in all touched tests

pull/3250/head
samyou-softwire 2 weeks ago
parent
commit
dafbac8063
  1. 28
      spec/models/bulk_upload_spec.rb
  2. 20
      spec/models/lettings_log_derived_fields_spec.rb
  3. 6
      spec/models/sales_log_spec.rb
  4. 4
      spec/models/validations/household_validations_spec.rb
  5. 4
      spec/models/validations/property_validations_spec.rb
  6. 2
      spec/models/validations/sales/sale_information_validations_spec.rb
  7. 6
      spec/models/validations/sales/soft_validations_spec.rb

28
spec/models/bulk_upload_spec.rb

@ -43,31 +43,9 @@ RSpec.describe BulkUpload, type: :model do
end end
end end
context "when 2026", metadata: { year: 26 } do context "when 2026 or later", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) } let(:startdate) { collection_start_date_for_year_or_later(2026) }
let(:saledate) { collection_start_date_for_year(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:) }
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 "with a lettings log bulk upload" do context "with a lettings log bulk upload" do
let(:log) { build(:lettings_log, startdate:, bulk_upload:) } let(:log) { build(:lettings_log, startdate:, bulk_upload:) }

20
spec/models/lettings_log_derived_fields_spec.rb

@ -1093,26 +1093,26 @@ RSpec.describe LettingsLog, type: :model do
end end
end end
context "when 2026", metadata: { year: 26 } do context "when 2026 or later", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) } 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 it "derives waityear offered referral first_time_property_let_as_social_housing rsnvac when renewal" do
log.renewal = 1 log.renewal = 1
expect { log.set_derived_fields! } expect { log.set_derived_fields! }
.to change(log, :waityear).to(2) .to change(log, :waityear).to(2)
.and change(log, :offered).to(0) .and change(log, :offered).to(0)
.and change(log, :referral_register).to(1) .and change(log, :referral_register).to(1)
.and change(log, :first_time_property_let_as_social_housing).to(0) .and change(log, :first_time_property_let_as_social_housing).to(0)
.and change(log, :rsnvac).to(14) .and change(log, :rsnvac).to(14)
end end
it "clears waityear offered referral first_time_property_let_as_social_housing rsnvac when not a renewal" do 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) } expect { persisted_renewal_lettings_log.update!(renewal: 0) }
.to change(persisted_renewal_lettings_log, :waityear).from(2).to(nil) .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, :offered).from(0).to(nil)
.and change(persisted_renewal_lettings_log, :referral_register).from(1).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, :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, :rsnvac).from(14).to(nil)
end end
end end

6
spec/models/sales_log_spec.rb

@ -712,7 +712,7 @@ RSpec.describe SalesLog, type: :model do
) )
end end
context "when 2025", metadata: { year: 2025 } do context "when 2025", metadata: { year: 25 } do
let(:saledate) { collection_start_date_for_year(2025) } let(:saledate) { collection_start_date_for_year(2025) }
let(:hholdcount) { 4 } let(:hholdcount) { 4 }
@ -743,8 +743,8 @@ RSpec.describe SalesLog, type: :model do
end end
end end
context "when 2026", metadata: { year: 2026 } do context "when 2026 or later", metadata: { year: 26 } do
let(:saledate) { collection_start_date_for_year(2026) } let(:saledate) { collection_start_date_for_year_or_later(2026) }
let(:hholdcount) { 6 } let(:hholdcount) { 6 }
it "correctly derives and saves hhmemb" do it "correctly derives and saves hhmemb" do

4
spec/models/validations/household_validations_spec.rb

@ -500,8 +500,8 @@ RSpec.describe Validations::HouseholdValidations do
end end
end end
context "when start year is 2026", metadata: { year: 26 } do context "when start year is 2026 or later", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) } let(:startdate) { collection_start_date_for_year_or_later(2026) }
[ [
{ {

4
spec/models/validations/property_validations_spec.rb

@ -370,8 +370,8 @@ RSpec.describe Validations::PropertyValidations do
end end
end end
context "when 2026", metadata: { year: 26 } do context "when 2026 or later", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) } let(:startdate) { collection_start_date_for_year_or_later(2026) }
context "and the local authority is active for supported housing log" do 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) } let(:log) { build(:lettings_log, :completed, startdate:, la: la_ecode_active, needstype: 2) }

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

@ -74,7 +74,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
end end
context "and form year is 2025 or later" do 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 it "does not add an error" do
sale_information_validator.validate_practical_completion_date(record) sale_information_validator.validate_practical_completion_date(record)

6
spec/models/validations/sales/soft_validations_spec.rb

@ -409,8 +409,8 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
end end
context "and 2026", metadata: { year: 26 } do context "and 2026 or later", metadata: { year: 26 } do
let(:saledate) { collection_start_date_for_year(2026) } 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 it "returns false if the deposit and mortgage add up to less than the discounted value" do
record.value = 500_000 record.value = 500_000
@ -423,7 +423,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
context "when validating extra borrowing" do 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 it "returns false for logs from 2024 onwards" do
record.extrabor = 2 record.extrabor = 2

Loading…
Cancel
Save