Browse Source

Update test

pull/72/head
baarkerlounger 4 years ago
parent
commit
cd41b0a133
  1. 10
      app/modules/soft_validations.rb
  2. 3
      spec/features/case_log_spec.rb

10
app/modules/soft_validations.rb

@ -1,21 +1,20 @@
module SoftValidations
def soft_errors
@soft_errors = {}
net_income_validations
@soft_errors
@soft_errors = {}.merge(net_income_validations)
end
private
def net_income_validations
net_income_errors = {}
if weekly_net_income && person_1_economic_status && override_net_income_validation.blank?
if weekly_net_income < applicable_income_range.soft_min && weekly_net_income > applicable_income_range.hard_min
@soft_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?",
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
@soft_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?",
hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}"
)
@ -25,5 +24,6 @@ module SoftValidations
self.update(override_net_income_validation: nil)
end
end
net_income_errors
end
end

3
spec/features/case_log_spec.rb

@ -385,6 +385,7 @@ RSpec.describe "Test Features" do
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")
@ -396,6 +397,7 @@ 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")
@ -408,6 +410,7 @@ 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")

Loading…
Cancel
Save