it"adds an error to stairbought and type if the percentage bought is less than the threshold (which is 1% by default, but higher for some shared ownership types)"do
record.stairbought=9
@ -307,7 +307,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
end
describe"#validate_child_income"do
let(:record){FactoryBot.create(:sales_log)}
let(:record){FactoryBot.build(:sales_log)}
context"when buyer 2 is not a child"do
beforedo
@ -352,17 +352,10 @@ RSpec.describe Validations::Sales::FinancialValidations do
expect(record.errors[:saledate]).toinclude("Enter a date within the 22/23 collection year, which is between 1st April 2022 and 31st March 2023")
expect(record.errors[:saledate]).toinclude(/Enter a date within the \d{2}\/\d{2} collection year, which is between 1st April \d{4} and 31st March \d{4}/)
end
end
context"when saledate is after the 22/23 collection year"do
expect(record.errors[:saledate]).toinclude("Enter a date within the 22/23 collection year, which is between 1st April 2022 and 31st March 2023")
expect(record.errors[:saledate]).toinclude(/Enter a date within the \d{2}\/\d{2} collection year, which is between 1st April \d{4} and 31st March \d{4}/)
expect(record.errors["saledate"]).toinclude(match"Enter a date within the 24/25 collection year, which is between 1st April 2024 and 31st March 2025")
expect(record.errors["saledate"]).toinclude(match"Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025")
end
xit"can edit already created logs for the previous collection year"do
it"can edit already created logs for the previous collection year"do
record.saledate=Time.zone.local(2024,1,2)
record.save!(validate:false)
record.saledate=Time.zone.local(2024,1,1)
@ -136,19 +126,19 @@ RSpec.describe Validations::Sales::SetupValidations do
expect(record.errors["saledate"]).toinclude(match"Enter a date within the 24/25 collection year, which is between 1st April 2024 and 31st March 2025")
expect(record.errors["saledate"]).toinclude(match"Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025")
end
it"cannot edit already created logs for the previous collection year"do
record.saledate=Time.zone.local(2024,1,2)
it"cannot edit already created logs for the archived collection year"do
expect(record.errors["saledate"]).toinclude(match"Enter a date within the 24/25 collection year, which is between 1st April 2024 and 31st March 2025")
expect(record.errors["saledate"]).toinclude(match"Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025")
end
end
end
@ -191,12 +181,6 @@ RSpec.describe Validations::Sales::SetupValidations do