Browse Source

Add carehome charges soft validation to 23/24 forms

pull/1410/head
Kat 3 years ago
parent
commit
5385126694
  1. 15
      app/models/form/lettings/pages/care_home_charges_value_check.rb
  2. 14
      app/models/form/lettings/questions/care_home_charges_value_check.rb
  3. 1
      app/models/form/lettings/subsections/income_and_benefits.rb
  4. 4
      app/models/lettings_log.rb
  5. 2
      config/locales/en.yml
  6. 44
      spec/models/form/lettings/pages/care_home_charges_value_check_spec.rb
  7. 56
      spec/models/form/lettings/questions/care_home_charges_value_check_spec.rb
  8. 1
      spec/models/form/lettings/subsections/income_and_benefits_spec.rb

15
app/models/form/lettings/pages/care_home_charges_value_check.rb

@ -0,0 +1,15 @@
class Form::Lettings::Pages::CareHomeChargesValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "care_home_charges_value_check"
@depends_on = [{ "care_home_charge_expected_not_provided?" => true }]
@title_text = {
"translation" => "soft_validations.care_home_charges.title_text",
}
@informative_text = ""
end
def questions
@questions ||= [Form::Lettings::Questions::CareHomeChargesValueCheck.new(nil, nil, self)]
end
end

14
app/models/form/lettings/questions/care_home_charges_value_check.rb

@ -0,0 +1,14 @@
class Form::Lettings::Questions::CareHomeChargesValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "carehome_charges_value_check"
@check_answer_label = "Care home charges confirmation"
@header = "Are you sure there are no care home charges?"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "carehome_charges_value_check" => 0 }, { "carehome_charges_value_check" => 1 }] }
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze
end

1
app/models/form/lettings/subsections/income_and_benefits.rb

@ -19,6 +19,7 @@ class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection
Form::Lettings::Pages::CareHomeBiWeekly.new(nil, nil, self),
Form::Lettings::Pages::CareHome4Weekly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeMonthly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeChargesValueCheck.new(nil, nil, self),
Form::Lettings::Pages::RentWeekly.new(nil, nil, self),
Form::Lettings::Pages::RentBiWeekly.new(nil, nil, self),
Form::Lettings::Pages::Rent4Weekly.new(nil, nil, self),

4
app/models/lettings_log.rb

@ -501,6 +501,10 @@ class LettingsLog < Log
update!(created_by: nil)
end
def care_home_charge_expected_not_provided?
true
end
private
def reset_derived_questions

2
config/locales/en.yml

@ -528,6 +528,8 @@ en:
discounted_sale_value:
title_text: "Mortgage, deposit, and grant total must equal £%{value_with_discount}"
informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}"
care_home_charges:
title_text: "Care home charges should be provided if this is a care home accommodation"
devise:
two_factor_authentication:

44
spec/models/form/lettings/pages/care_home_charges_value_check_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::CareHomeChargesValueCheck, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do
expect(page.description).to be nil
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[carehome_charges_value_check])
end
it "has the correct id" do
expect(page.id).to eq("care_home_charges_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "care_home_charge_expected_not_provided?" => true }],
)
end
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.care_home_charges.title_text",
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq("")
end
end

56
spec/models/form/lettings/questions/care_home_charges_value_check_spec.rb

@ -0,0 +1,56 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::CareHomeChargesValueCheck, type: :model do
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("carehome_charges_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure there are no care home charges?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Care home charges confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"carehome_charges_value_check" => 0,
},
{
"carehome_charges_value_check" => 1,
},
],
})
end
end

1
spec/models/form/lettings/subsections/income_and_benefits_spec.rb

@ -25,6 +25,7 @@ RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do
care_home_bi_weekly
care_home_4_weekly
care_home_monthly
care_home_charges_value_check
rent_weekly
rent_bi_weekly
rent_4_weekly

Loading…
Cancel
Save