|
|
|
@ -511,6 +511,59 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
expect(record.errors["scheme_id"]).to be_empty |
|
|
|
expect(record.errors["scheme_id"]).to be_empty |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with a scheme with no locations active on the start date & no location set" do |
|
|
|
|
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
|
|
|
|
let(:location) { create(:location, scheme:) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
location_deactivation_period = build(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), location:) |
|
|
|
|
|
|
|
location_deactivation_period.save!(validate: false) |
|
|
|
|
|
|
|
location.reload |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces error when scheme does not have any active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 7, 5) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to include(match I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: scheme.service_name)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when scheme has active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 6, 1) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with a scheme with no locations active on the start date & location also set" do |
|
|
|
|
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
|
|
|
|
let(:location) { create(:location, scheme:) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
location_deactivation_period = build(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), location:) |
|
|
|
|
|
|
|
location_deactivation_period.save!(validate: false) |
|
|
|
|
|
|
|
location.reload |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces error when scheme does not have any active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 7, 5) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
record.location = location |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to include(match I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: scheme.service_name)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when scheme has active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 6, 1) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
record.location = location |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#validate_location" do |
|
|
|
describe "#validate_location" do |
|
|
|
@ -647,60 +700,6 @@ RSpec.describe Validations::SetupValidations do |
|
|
|
expect(record.errors["location_id"]).to be_empty |
|
|
|
expect(record.errors["location_id"]).to be_empty |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "validate_tenancy" do |
|
|
|
|
|
|
|
context "with a scheme with no locations active on the start date & no location set" do |
|
|
|
|
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
|
|
|
|
let(:location) { create(:location, scheme:) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
location_deactivation_period = build(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), location:) |
|
|
|
|
|
|
|
location_deactivation_period.save!(validate: false) |
|
|
|
|
|
|
|
location.reload |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces error when scheme does not have any active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 7, 5) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to include(match I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: scheme.service_name)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when scheme has active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 6, 1) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with a scheme with no locations active on the start date & location also set" do |
|
|
|
|
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
|
|
|
|
let(:location) { create(:location, scheme:) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
location_deactivation_period = build(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), location:) |
|
|
|
|
|
|
|
location_deactivation_period.save!(validate: false) |
|
|
|
|
|
|
|
location.reload |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces error when scheme does not have any active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 7, 5) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
record.location = location |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to include(match I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: scheme.service_name)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "produces no error when scheme has active locations on the tenancy start date" do |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 6, 1) |
|
|
|
|
|
|
|
record.scheme = scheme |
|
|
|
|
|
|
|
record.location = location |
|
|
|
|
|
|
|
setup_validator.validate_tenancy(record) |
|
|
|
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with the chosen location inactive on the start date" do |
|
|
|
context "with the chosen location inactive on the start date" do |
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
|