Browse Source

Add referral value check to 2023

pull/1910/head
Kat 3 years ago
parent
commit
47426aa1b1
  1. 19
      app/models/form/lettings/pages/referral_value_check.rb
  2. 14
      app/models/form/lettings/questions/referral_value_check.rb
  3. 1
      app/models/form/lettings/subsections/household_situation.rb
  4. 4
      app/models/lettings_log.rb
  5. 30
      spec/models/validations/soft_validations_spec.rb

19
app/models/form/lettings/pages/referral_value_check.rb

@ -0,0 +1,19 @@
class Form::Lettings::Pages::ReferralValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "referral_value_check"
@depends_on = [{ "la_referral_for_general_needs?" => true }]
@title_text = {
"translation" => "soft_validations.referral.title_text",
}
@informative_text = ""
end
def questions
@questions ||= [Form::Lettings::Questions::ReferralValueCheck.new(nil, nil, self)]
end
def interruption_screen_question_ids
%w[needstype referral]
end
end

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

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

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

@ -24,6 +24,7 @@ class Form::Lettings::Subsections::HouseholdSituation < ::Form::Subsection
Form::Lettings::Pages::ReferralPrp.new(nil, nil, self), Form::Lettings::Pages::ReferralPrp.new(nil, nil, self),
Form::Lettings::Pages::ReferralSupportedHousing.new(nil, nil, self), Form::Lettings::Pages::ReferralSupportedHousing.new(nil, nil, self),
Form::Lettings::Pages::ReferralSupportedHousingPrp.new(nil, nil, self), Form::Lettings::Pages::ReferralSupportedHousingPrp.new(nil, nil, self),
Form::Lettings::Pages::ReferralValueCheck.new(nil, nil, self),
].compact ].compact
end end
end end

4
app/models/lettings_log.rb

@ -568,6 +568,10 @@ class LettingsLog < Log
end end
end end
def la_referral_for_general_needs?
is_general_needs? && referral == 4
end
private private
def reset_invalid_unresolved_log_fields! def reset_invalid_unresolved_log_fields!

30
spec/models/validations/soft_validations_spec.rb

@ -345,4 +345,34 @@ RSpec.describe Validations::SoftValidations do
expect(record).to be_care_home_charge_expected_not_provided expect(record).to be_care_home_charge_expected_not_provided
end end
end end
describe "#la_referral_for_general_needs?" do
it "returns false if needstype is 'Supported Housing'" do
record.needstype = 2
record.referral = 4
expect(record).not_to be_la_referral_for_general_needs
end
it "returns false if needstype is not given" do
record.needstype = nil
record.referral = 4
expect(record).not_to be_la_referral_for_general_needs
end
it "returns false if referral is not given" do
record.needstype = 1
record.referral = nil
expect(record).not_to be_la_referral_for_general_needs
end
it "returns true if needstype is 'General needs' and referral is 4" do
record.needstype = 1
record.referral = 4
expect(record).to be_la_referral_for_general_needs
end
end
end end

Loading…
Cancel
Save