|
|
@ -18,26 +18,6 @@ RSpec.describe CaseLog do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#new" do |
|
|
|
describe "#new" do |
|
|
|
it "raises an error when offered is present and invalid" do |
|
|
|
|
|
|
|
expect { |
|
|
|
|
|
|
|
described_class.create!( |
|
|
|
|
|
|
|
offered: "random", |
|
|
|
|
|
|
|
owning_organisation: owning_organisation, |
|
|
|
|
|
|
|
managing_organisation: managing_organisation, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}.to raise_error(ActiveRecord::RecordInvalid) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "raises an error when previous_postcode is present and invalid" do |
|
|
|
|
|
|
|
expect { |
|
|
|
|
|
|
|
described_class.create!( |
|
|
|
|
|
|
|
previous_postcode: "invalid_postcode", |
|
|
|
|
|
|
|
owning_organisation: owning_organisation, |
|
|
|
|
|
|
|
managing_organisation: managing_organisation, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}.to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.postcode")}/) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates age is a number" do |
|
|
|
it "validates age is a number" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
described_class.create!( |
|
|
|
described_class.create!( |
|
|
@ -89,15 +69,6 @@ RSpec.describe CaseLog do |
|
|
|
}.to raise_error(ActiveRecord::RecordInvalid) |
|
|
|
}.to raise_error(ActiveRecord::RecordInvalid) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "validates bedroom number" do |
|
|
|
|
|
|
|
expect { |
|
|
|
|
|
|
|
described_class.create!(unittype_gn: "Shared house", |
|
|
|
|
|
|
|
beds: 0, |
|
|
|
|
|
|
|
owning_organisation: owning_organisation, |
|
|
|
|
|
|
|
managing_organisation: managing_organisation) |
|
|
|
|
|
|
|
}.to raise_error(ActiveRecord::RecordInvalid) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when a reasonable preference is set to yes" do |
|
|
|
context "when a reasonable preference is set to yes" do |
|
|
|
it "validates that previously homeless should be selected" do |
|
|
|
it "validates that previously homeless should be selected" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
@ -357,17 +328,6 @@ RSpec.describe CaseLog do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when validating fixed term tenancy" do |
|
|
|
|
|
|
|
it "Must not be completed if Type of main tenancy is not responded with either Secure or Assured shorthold " do |
|
|
|
|
|
|
|
expect { |
|
|
|
|
|
|
|
described_class.create!(tenancy: "Other", |
|
|
|
|
|
|
|
tenancylength: 10, |
|
|
|
|
|
|
|
owning_organisation: owning_organisation, |
|
|
|
|
|
|
|
managing_organisation: managing_organisation) |
|
|
|
|
|
|
|
}.to raise_error(ActiveRecord::RecordInvalid) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when validating armed forces is active" do |
|
|
|
context "when validating armed forces is active" do |
|
|
|
it "must not be answered if not ever served as a regular" do |
|
|
|
it "must not be answered if not ever served as a regular" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
@ -800,6 +760,35 @@ RSpec.describe CaseLog do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "#update" do |
|
|
|
|
|
|
|
let(:case_log) { FactoryBot.create(:case_log) } |
|
|
|
|
|
|
|
let(:validator) { case_log._validators[nil].first } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
after do |
|
|
|
|
|
|
|
case_log.update(age1: 25) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates bedroom number" do |
|
|
|
|
|
|
|
expect(validator).to receive(:validate_shared_housing_rooms) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates number of times the property has been relet" do |
|
|
|
|
|
|
|
expect(validator).to receive(:validate_property_number_of_times_relet) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates tenancy length for tenancy type" do |
|
|
|
|
|
|
|
expect(validator).to receive(:validate_fixed_term_tenancy) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates the previous postcode" do |
|
|
|
|
|
|
|
expect(validator).to receive(:validate_previous_accommodation_postcode) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates the net income" do |
|
|
|
|
|
|
|
expect(validator).to receive(:validate_net_income) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "status" do |
|
|
|
describe "status" do |
|
|
|
let!(:empty_case_log) { FactoryBot.create(:case_log) } |
|
|
|
let!(:empty_case_log) { FactoryBot.create(:case_log) } |
|
|
|
let!(:in_progress_case_log) { FactoryBot.create(:case_log, :in_progress) } |
|
|
|
let!(:in_progress_case_log) { FactoryBot.create(:case_log, :in_progress) } |
|
|
|