|
|
@ -6,6 +6,10 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
let(:setup_validator_class) { Class.new { include Validations::SetupValidations } } |
|
|
|
let(:setup_validator_class) { Class.new { include Validations::SetupValidations } } |
|
|
|
let(:record) { FactoryBot.create(:lettings_log) } |
|
|
|
let(:record) { FactoryBot.create(:lettings_log) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(FeatureToggle).to receive(:startdate_validation_enabled?).and_return(true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "tenancy start date" do |
|
|
|
describe "tenancy start date" do |
|
|
|
context "when in 22/23 collection" do |
|
|
|
context "when in 22/23 collection" do |
|
|
|
context "when in the crossover period" do |
|
|
|
context "when in the crossover period" do |
|
|
@ -94,7 +98,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.irproduct_other = nil |
|
|
|
record.irproduct_other = nil |
|
|
|
setup_validator.validate_irproduct_other(record) |
|
|
|
setup_validator.validate_irproduct_other(record) |
|
|
|
expect(record.errors["irproduct_other"]) |
|
|
|
expect(record.errors["irproduct_other"]) |
|
|
|
.to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank")) |
|
|
|
.to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "adds an error when the intermediate rent product name is blank but the rent type was given as other intermediate rent product" do |
|
|
|
it "adds an error when the intermediate rent product name is blank but the rent type was given as other intermediate rent product" do |
|
|
@ -102,7 +106,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.irproduct_other = "" |
|
|
|
record.irproduct_other = "" |
|
|
|
setup_validator.validate_irproduct_other(record) |
|
|
|
setup_validator.validate_irproduct_other(record) |
|
|
|
expect(record.errors["irproduct_other"]) |
|
|
|
expect(record.errors["irproduct_other"]) |
|
|
|
.to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank")) |
|
|
|
.to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "Does not add an error when the intermediate rent product name is provided and the rent type was given as other intermediate rent product" do |
|
|
|
it "Does not add an error when the intermediate rent product name is provided and the rent type was given as other intermediate rent product" do |
|
|
@ -128,7 +132,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.location = location |
|
|
|
record.location = location |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.deactivated", postcode: location.postcode, date: "4 June 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.deactivated", postcode: location.postcode, date: "4 June 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
@ -153,7 +157,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.location = location |
|
|
|
record.location = location |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.reactivating_soon", postcode: location.postcode, date: "4 August 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.reactivating_soon", postcode: location.postcode, date: "4 August 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
@ -180,7 +184,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.location = location |
|
|
|
record.location = location |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.activating_soon", postcode: location.postcode, date: "15 September 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.activating_soon", postcode: location.postcode, date: "15 September 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -197,7 +201,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.scheme = scheme |
|
|
|
record.scheme = scheme |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.scheme.reactivating_soon", name: scheme.service_name, date: "4 August 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.scheme.reactivating_soon", name: scheme.service_name, date: "4 August 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when tenancy start date is during an active scheme period" do |
|
|
|
it "produces no error when tenancy start date is during an active scheme period" do |
|
|
@ -223,7 +227,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.scheme = scheme |
|
|
|
record.scheme = scheme |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
setup_validator.validate_scheme(record) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
expect(record.errors["scheme_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.scheme.reactivating_soon", name: scheme.service_name, date: "4 September 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.scheme.reactivating_soon", name: scheme.service_name, date: "4 September 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when tenancy start date is during an active scheme period" do |
|
|
|
it "produces no error when tenancy start date is during an active scheme period" do |
|
|
@ -250,7 +254,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.location = location |
|
|
|
record.location = location |
|
|
|
setup_validator.validate_location(record) |
|
|
|
setup_validator.validate_location(record) |
|
|
|
expect(record.errors["location_id"]) |
|
|
|
expect(record.errors["location_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.deactivated", postcode: location.postcode, date: "4 June 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.deactivated", postcode: location.postcode, date: "4 June 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
@ -275,7 +279,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.location = location |
|
|
|
record.location = location |
|
|
|
setup_validator.validate_location(record) |
|
|
|
setup_validator.validate_location(record) |
|
|
|
expect(record.errors["location_id"]) |
|
|
|
expect(record.errors["location_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.reactivating_soon", postcode: location.postcode, date: "4 August 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.reactivating_soon", postcode: location.postcode, date: "4 August 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
|
it "produces no error when tenancy start date is during an active location period" do |
|
|
@ -302,7 +306,7 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
record.location = location |
|
|
|
record.location = location |
|
|
|
setup_validator.validate_location(record) |
|
|
|
setup_validator.validate_location(record) |
|
|
|
expect(record.errors["location_id"]) |
|
|
|
expect(record.errors["location_id"]) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.activating_soon", postcode: location.postcode, date: "15 September 2022")) |
|
|
|
.to include(match I18n.t("validations.setup.startdate.location.activating_soon", postcode: location.postcode, date: "15 September 2022")) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|