diff --git a/app/models/income_range.rb b/app/models/income_range.rb index b21b1fa57..2d0013d33 100644 --- a/app/models/income_range.rb +++ b/app/models/income_range.rb @@ -10,6 +10,6 @@ class IncomeRange "Unable to work because of long term sick or disability": OpenStruct.new(soft_min: 54, soft_max: 460, hard_min: 10, hard_max: 820), "Child under 16": OpenStruct.new(soft_min: 50, soft_max: 450, hard_min: 10, hard_max: 750), "Other": OpenStruct.new(soft_min: 50, soft_max: 580, hard_min: 10, hard_max: 1040), - "Prefer not to say": OpenStruct.new(soft_min: 47, soft_max: 730, hard_min: 10, hard_max: 1300) - } + "Prefer not to say": OpenStruct.new(soft_min: 47, soft_max: 730, hard_min: 10, hard_max: 1300), + }.freeze end diff --git a/app/modules/soft_validations.rb b/app/modules/soft_validations.rb index 245b8820a..f22c53946 100644 --- a/app/modules/soft_validations.rb +++ b/app/modules/soft_validations.rb @@ -3,7 +3,7 @@ module SoftValidations @soft_errors = {}.merge(net_income_validations) end - private +private def net_income_validations net_income_errors = {} @@ -11,17 +11,17 @@ module SoftValidations if weekly_net_income < applicable_income_range.soft_min && weekly_net_income > applicable_income_range.hard_min net_income_errors["weekly_net_income"] = OpenStruct.new( message: "Net income is lower than expected based on the main tenant's working situation. Are you sure this is correct?", - hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}" + hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}", ) elsif weekly_net_income > applicable_income_range.soft_max && weekly_net_income < applicable_income_range.hard_max net_income_errors["weekly_net_income"] = OpenStruct.new( message: "Net income is higher than expected based on the main tenant's working situation. Are you sure this is correct?", - hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}" + hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}", ) end elsif weekly_net_income && person_1_economic_status && override_net_income_validation.present? if weekly_net_income > applicable_income_range.soft_min && weekly_net_income < applicable_income_range.soft_max - self.update(override_net_income_validation: nil) + update!(override_net_income_validation: nil) end end net_income_errors diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index b09135308..e59360513 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -379,13 +379,12 @@ RSpec.describe "Test Features" do describe "Soft Validation" do context "given a weekly net income that is above the expected amount for the given economic status but below the hard max" do - let!(:case_log){ FactoryBot.create(:case_log, :in_progress, person_1_economic_status: "Full-time - 30 hours or more") } + let!(:case_log) { FactoryBot.create(:case_log, :in_progress, person_1_economic_status: "Full-time - 30 hours or more") } let(:income_over_soft_limit) { 750 } let(:income_under_soft_limit) { 700 } it "prompts the user to confirm the value is correct" do visit("/case_logs/#{case_log.id}/net_income") - choose("case-log-net-income-known-yes-field", allow_label_click: true) fill_in("case-log-net-income-field", with: income_over_soft_limit) choose("case-log-net-income-frequency-weekly-field", allow_label_click: true) click_button("Save and continue") @@ -397,7 +396,6 @@ RSpec.describe "Test Features" do it "does not require confirming the value if the value is amended" do visit("/case_logs/#{case_log.id}/net_income") - choose("case-log-net-income-known-yes-field", allow_label_click: true) fill_in("case-log-net-income-field", with: income_over_soft_limit) choose("case-log-net-income-frequency-weekly-field", allow_label_click: true) click_button("Save and continue") @@ -410,7 +408,6 @@ RSpec.describe "Test Features" do xit "clears the confirmation question if the page is returned to using the back button" do visit("/case_logs/#{case_log.id}/net_income") - choose("case-log-net-income-known-yes-field", allow_label_click: true) fill_in("case-log-net-income-field", with: income_over_soft_limit) choose("case-log-net-income-frequency-weekly-field", allow_label_click: true) click_button("Save and continue")