|
|
|
|
@ -47,12 +47,12 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#validate_pratical_completion_date_before_saledate" do |
|
|
|
|
describe "#validate_practical_completion_date_before_saledate" do |
|
|
|
|
context "when hodate blank" do |
|
|
|
|
let(:record) { build(:sales_log, hodate: nil) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_pratical_completion_date_before_saledate(record) |
|
|
|
|
sale_information_validator.validate_practical_completion_date_before_saledate(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
@ -62,7 +62,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
let(:record) { build(:sales_log, saledate: nil) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_pratical_completion_date_before_saledate(record) |
|
|
|
|
sale_information_validator.validate_practical_completion_date_before_saledate(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
@ -72,7 +72,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
let(:record) { build(:sales_log, hodate: nil, saledate: nil) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_pratical_completion_date_before_saledate(record) |
|
|
|
|
sale_information_validator.validate_practical_completion_date_before_saledate(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
@ -82,7 +82,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
let(:record) { build(:sales_log, hodate: 2.months.ago, saledate: 1.month.ago) } |
|
|
|
|
|
|
|
|
|
it "does not add the error" do |
|
|
|
|
sale_information_validator.validate_pratical_completion_date_before_saledate(record) |
|
|
|
|
sale_information_validator.validate_practical_completion_date_before_saledate(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
@ -92,7 +92,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
let(:record) { build(:sales_log, hodate: 1.month.ago, saledate: 2.months.ago) } |
|
|
|
|
|
|
|
|
|
it "adds error" do |
|
|
|
|
sale_information_validator.validate_pratical_completion_date_before_saledate(record) |
|
|
|
|
sale_information_validator.validate_practical_completion_date_before_saledate(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors[:hodate]).to be_present |
|
|
|
|
end |
|
|
|
|
@ -102,10 +102,63 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
let(:record) { build(:sales_log, hodate: Time.zone.parse("2023-07-01"), saledate: Time.zone.parse("2023-07-01")) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_pratical_completion_date_before_saledate(record) |
|
|
|
|
sale_information_validator.validate_practical_completion_date_before_saledate(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors[:hodate]).to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#validate_years_living_in_property_before_purchase" do |
|
|
|
|
context "when proplen blank" do |
|
|
|
|
let(:record) { build(:sales_log, proplen: nil) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_years_living_in_property_before_purchase(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when type blank" do |
|
|
|
|
let(:record) { build(:sales_log, type: nil) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_years_living_in_property_before_purchase(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when proplen 0" do |
|
|
|
|
let(:record) { build(:sales_log, proplen: 0) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_years_living_in_property_before_purchase(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).not_to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when type Rent to Buy and proplen > 0" do |
|
|
|
|
let(:record) { build(:sales_log, proplen: 1, type: 28) } |
|
|
|
|
|
|
|
|
|
it "adds an error" do |
|
|
|
|
sale_information_validator.validate_years_living_in_property_before_purchase(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when type Social HomeBuy and proplen > 0" do |
|
|
|
|
let(:record) { build(:sales_log, proplen: 1, type: 18) } |
|
|
|
|
|
|
|
|
|
it "adds an error" do |
|
|
|
|
sale_information_validator.validate_years_living_in_property_before_purchase(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors).to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|