Browse Source

Accessibility requirement specs

pull/307/head
baarkerlounger 3 years ago
parent
commit
f257eb527c
  1. 55
      spec/models/case_log_spec.rb
  2. 41
      spec/models/validations/household_validations_spec.rb

55
spec/models/case_log_spec.rb

@ -75,61 +75,6 @@ RSpec.describe CaseLog do
end end
end end
end end
context "with accessibility requirements" do
it "validates that only one option can be selected" do
expect {
described_class.create!(housingneeds_a: "Yes",
housingneeds_b: "Yes",
rent_type: "London Affordable rent",
owning_organisation:,
managing_organisation:)
}.to raise_error(ActiveRecord::RecordInvalid)
end
it "validates that only one option a, b, or c can be selected in conjunction with f" do
expect {
described_class.create!(housingneeds_a: "Yes",
housingneeds_f: "Yes",
rent_type: "London Affordable rent",
owning_organisation:,
managing_organisation:)
}.not_to raise_error
expect {
described_class.create!(housingneeds_b: "Yes",
housingneeds_f: "Yes",
rent_type: "London Affordable rent",
owning_organisation:,
managing_organisation:)
}.not_to raise_error
expect {
described_class.create!(housingneeds_c: "Yes",
housingneeds_f: "Yes",
rent_type: "London Affordable rent",
owning_organisation:,
managing_organisation:)
}.not_to raise_error
expect {
described_class.create!(housingneeds_g: "Yes",
housingneeds_f: "Yes",
rent_type: "London Affordable rent",
owning_organisation:,
managing_organisation:)
}.to raise_error(ActiveRecord::RecordInvalid)
expect {
described_class.create!(housingneeds_a: "Yes",
housingneeds_b: "Yes",
housingneeds_f: "Yes",
rent_type: "London Affordable rent",
owning_organisation:,
managing_organisation:)
}.to raise_error(ActiveRecord::RecordInvalid)
end
end
# END TODO # END TODO
end end

41
spec/models/validations/household_validations_spec.rb

@ -437,4 +437,45 @@ RSpec.describe Validations::HouseholdValidations do
end end
end end
end end
describe "accessibility requirement validations" do
it "validates that mutually exclusive options can't be selected together" do
record.housingneeds_a = "Yes"
record.housingneeds_b = "Yes"
household_validator.validate_accessibility_requirements(record)
expect(record.errors["accessibility_requirements"])
.to include(match I18n.t("validations.household.housingneeds_a.one_or_two_choices"))
record.housingneeds_a = "No"
record.housingneeds_b = "No"
record.housingneeds_g = "Yes"
record.housingneeds_f = "Yes"
household_validator.validate_accessibility_requirements(record)
expect(record.errors["accessibility_requirements"])
.to include(match I18n.t("validations.household.housingneeds_a.one_or_two_choices"))
record.housingneeds_a = "Yes"
record.housingneeds_g = "Yes"
record.housingneeds_f = "Yes"
household_validator.validate_accessibility_requirements(record)
expect(record.errors["accessibility_requirements"])
.to include(match I18n.t("validations.household.housingneeds_a.one_or_two_choices"))
end
it "validates that non-mutually exclusive options can be selected together" do
record.housingneeds_a = "Yes"
record.housingneeds_f = "Yes"
household_validator.validate_accessibility_requirements(record)
expect(record.errors["accessibility_requirements"]).to be_empty
record.housingneeds_a = "No"
record.housingneeds_b = "Yes"
record.housingneeds_f = "Yes"
household_validator.validate_accessibility_requirements(record)
expect(record.errors["accessibility_requirements"]).to be_empty
record.housingneeds_b = "No"
record.housingneeds_c = "Yes"
record.housingneeds_f = "Yes"
household_validator.validate_accessibility_requirements(record)
expect(record.errors["accessibility_requirements"]).to be_empty
end
end
end end

Loading…
Cancel
Save