Browse Source

Rubocop

pull/72/head
baarkerlounger 4 years ago
parent
commit
1864fdd3b3
  1. 2
      app/models/case_log.rb
  2. 10
      app/validations/household_validations.rb
  3. 2
      spec/features/case_log_spec.rb

2
app/models/case_log.rb

@ -41,7 +41,7 @@ class CaseLog < ApplicationRecord
default_scope -> { kept } default_scope -> { kept }
scope :not_completed, -> { where.not(status: "completed") } scope :not_completed, -> { where.not(status: "completed") }
validates_with CaseLogValidator, ({ page: @page } || {}) validates_with CaseLogValidator, ({ page: @page } || {})
before_save :update_status! before_save :update_status!
attr_accessor :page attr_accessor :page

10
app/validations/household_validations.rb

@ -62,15 +62,11 @@ module HouseholdValidations
record.errors.add :property_unit_type, "A bedsit can only have one bedroom" record.errors.add :property_unit_type, "A bedsit can only have one bedroom"
end end
unless record.household_number_of_other_members.nil? if !record.household_number_of_other_members.nil? && record.household_number_of_other_members.positive? && (record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 7))
if record.household_number_of_other_members > 0 record.errors.add :property_unit_type, "A shared house must have 1 to 7 bedrooms"
if record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 7)
record.errors.add :property_unit_type, "A shared house must have 1 to 7 bedrooms"
end
end
end end
if record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 3) if record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 3)
record.errors.add :property_unit_type, "A shared house with less than two tenants must have 1 to 3 bedrooms" record.errors.add :property_unit_type, "A shared house with less than two tenants must have 1 to 3 bedrooms"
end end
end end

2
spec/features/case_log_spec.rb

@ -233,7 +233,7 @@ RSpec.describe "Test Features" do
context "when changing an answer from the check answers page" do context "when changing an answer from the check answers page" do
it "the back button routes correctly" do it "the back button routes correctly" do
visit("/case_logs/#{id}/household_characteristics/check_answers") visit("/case_logs/#{id}/household_characteristics/check_answers")
first("a", text: /Answer/).click first("a", text: /Answer/).click
click_link("Back") click_link("Back")
expect(page).to have_current_path("/case_logs/#{id}/household_characteristics/check_answers") expect(page).to have_current_path("/case_logs/#{id}/household_characteristics/check_answers")
end end

Loading…
Cancel
Save