|
|
|
@ -177,41 +177,41 @@ RSpec.describe Validations::SharedValidations do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#validate_previous_accommodation_postcode" do |
|
|
|
describe "#validate_previous_accommodation_postcode" do |
|
|
|
it "does not add an error if the record ppostcode_full is missing when postcode not known" do |
|
|
|
it "does not add an error if the lettings_log ppostcode_full is missing when postcode not known" do |
|
|
|
record.ppcodenk = 2 |
|
|
|
lettings_log.ppcodenk = 2 |
|
|
|
record.ppostcode_full = nil |
|
|
|
lettings_log.ppostcode_full = nil |
|
|
|
shared_validator.validate_previous_accommodation_postcode(record) |
|
|
|
shared_validator.validate_previous_accommodation_postcode(lettings_log) |
|
|
|
expect(record.errors).to be_empty |
|
|
|
expect(lettings_log.errors).to be_empty |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does add an error if the record ppostcode_full is missing when postcode is known" do |
|
|
|
it "does add an error if the lettings_log ppostcode_full is missing when postcode is known" do |
|
|
|
record.ppcodenk = 1 |
|
|
|
lettings_log.ppcodenk = 1 |
|
|
|
record.ppostcode_full = nil |
|
|
|
lettings_log.ppostcode_full = nil |
|
|
|
shared_validator.validate_previous_accommodation_postcode(record) |
|
|
|
shared_validator.validate_previous_accommodation_postcode(lettings_log) |
|
|
|
expect(record.errors).not_to be_empty |
|
|
|
expect(lettings_log.errors).not_to be_empty |
|
|
|
expect(record.errors["ppostcode_full"].first).to eq(I18n.t("validations.postcode")) |
|
|
|
expect(lettings_log.errors["ppostcode_full"].first).to eq(I18n.t("validations.postcode")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does not add an error if the record ppostcode_full is valid (uppercase space)" do |
|
|
|
it "does not add an error if the lettings_log ppostcode_full is valid (uppercase space)" do |
|
|
|
record.ppcodenk = 1 |
|
|
|
lettings_log.ppcodenk = 1 |
|
|
|
record.ppostcode_full = "M1 1AE" |
|
|
|
lettings_log.ppostcode_full = "M1 1AE" |
|
|
|
shared_validator.validate_previous_accommodation_postcode(record) |
|
|
|
shared_validator.validate_previous_accommodation_postcode(lettings_log) |
|
|
|
expect(record.errors).to be_empty |
|
|
|
expect(lettings_log.errors).to be_empty |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does not add an error if the record ppostcode_full is valid (lowercase no space)" do |
|
|
|
it "does not add an error if the lettings_log ppostcode_full is valid (lowercase no space)" do |
|
|
|
record.ppcodenk = 1 |
|
|
|
lettings_log.ppcodenk = 1 |
|
|
|
record.ppostcode_full = "m11ae" |
|
|
|
lettings_log.ppostcode_full = "m11ae" |
|
|
|
shared_validator.validate_previous_accommodation_postcode(record) |
|
|
|
shared_validator.validate_previous_accommodation_postcode(lettings_log) |
|
|
|
expect(record.errors).to be_empty |
|
|
|
expect(lettings_log.errors).to be_empty |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does add an error when the postcode is invalid" do |
|
|
|
it "does add an error when the postcode is invalid" do |
|
|
|
record.ppcodenk = 1 |
|
|
|
lettings_log.ppcodenk = 1 |
|
|
|
record.ppostcode_full = "invalid" |
|
|
|
lettings_log.ppostcode_full = "invalid" |
|
|
|
shared_validator.validate_previous_accommodation_postcode(record) |
|
|
|
shared_validator.validate_previous_accommodation_postcode(lettings_log) |
|
|
|
expect(record.errors).not_to be_empty |
|
|
|
expect(lettings_log.errors).not_to be_empty |
|
|
|
expect(record.errors["ppostcode_full"].first).to eq(I18n.t("validations.postcode")) |
|
|
|
expect(lettings_log.errors["ppostcode_full"].first).to eq(I18n.t("validations.postcode")) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|