|
|
|
@ -171,60 +171,6 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
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[:type]).to include(I18n.t("validations.sale_information.proplen.rent_to_buy")) |
|
|
|
|
expect(record.errors[:proplen]).to include(I18n.t("validations.sale_information.proplen.rent_to_buy")) |
|
|
|
|
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[:type]).to include(I18n.t("validations.sale_information.proplen.social_homebuy")) |
|
|
|
|
expect(record.errors[:proplen]).to include(I18n.t("validations.sale_information.proplen.social_homebuy")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#validate_discounted_ownership_value" do |
|
|
|
|
context "when sale is on or after 24/25 collection window" do |
|
|
|
|
context "when grant is routed to" do |
|
|
|
|