Browse Source

Rubocop

pull/72/head
baarkerlounger 4 years ago
parent
commit
0aca7ad716
  1. 4
      app/models/income_range.rb
  2. 6
      app/modules/soft_validations.rb
  3. 3
      spec/features/case_log_spec.rb

4
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), "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), "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), "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 end

6
app/modules/soft_validations.rb

@ -11,17 +11,17 @@ module SoftValidations
if weekly_net_income < applicable_income_range.soft_min && weekly_net_income > applicable_income_range.hard_min 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( 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?", 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 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( 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?", 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 end
elsif weekly_net_income && person_1_economic_status && override_net_income_validation.present? 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 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
end end
net_income_errors net_income_errors

3
spec/features/case_log_spec.rb

@ -385,7 +385,6 @@ RSpec.describe "Test Features" do
it "prompts the user to confirm the value is correct" do it "prompts the user to confirm the value is correct" do
visit("/case_logs/#{case_log.id}/net_income") 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) fill_in("case-log-net-income-field", with: income_over_soft_limit)
choose("case-log-net-income-frequency-weekly-field", allow_label_click: true) choose("case-log-net-income-frequency-weekly-field", allow_label_click: true)
click_button("Save and continue") 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 it "does not require confirming the value if the value is amended" do
visit("/case_logs/#{case_log.id}/net_income") 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) fill_in("case-log-net-income-field", with: income_over_soft_limit)
choose("case-log-net-income-frequency-weekly-field", allow_label_click: true) choose("case-log-net-income-frequency-weekly-field", allow_label_click: true)
click_button("Save and continue") 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 xit "clears the confirmation question if the page is returned to using the back button" do
visit("/case_logs/#{case_log.id}/net_income") 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) fill_in("case-log-net-income-field", with: income_over_soft_limit)
choose("case-log-net-income-frequency-weekly-field", allow_label_click: true) choose("case-log-net-income-frequency-weekly-field", allow_label_click: true)
click_button("Save and continue") click_button("Save and continue")

Loading…
Cancel
Save