|
|
|
@ -38,35 +38,12 @@ RSpec.describe Validations::LocalAuthorityValidations do
|
|
|
|
|
|
|
|
|
|
describe "#validate_la" do |
|
|
|
|
context "when the rent type is London affordable" do |
|
|
|
|
let(:expected_error) { I18n.t("validations.property.la.london_rent") } |
|
|
|
|
|
|
|
|
|
it "validates that the local authority is in London" do |
|
|
|
|
record.la = "E07000105" |
|
|
|
|
record.rent_type = 2 |
|
|
|
|
local_auth_validator.validate_la(record) |
|
|
|
|
expect(record.errors["la"]).to include(match(expected_error)) |
|
|
|
|
expect(record.errors["postcode_full"]).to be_empty |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "expects that the local authority is in London" do |
|
|
|
|
record.la = "E09000033" |
|
|
|
|
record.rent_type = 2 |
|
|
|
|
local_auth_validator.validate_la(record) |
|
|
|
|
expect(record.errors["la"]).to be_empty |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the la has been derived from a known postcode" do |
|
|
|
|
let(:expected_error) { I18n.t("validations.property.la.london_rent_postcode") } |
|
|
|
|
|
|
|
|
|
it "also adds an error to the postcode field" do |
|
|
|
|
record.la = "E07000105" |
|
|
|
|
record.rent_type = 2 |
|
|
|
|
record.postcode_known = 1 |
|
|
|
|
record.postcode_full = "BN18 7TR" |
|
|
|
|
local_auth_validator.validate_la(record) |
|
|
|
|
expect(record.errors["postcode_full"]).to include(match(expected_error)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when previous la is known" do |
|
|
|
|