Browse Source

CLDC-1543 Route to mortgage questions only if mortgage is used (#1179)

* Route to mortagage questions only if mortgage is used

* Fix tests for deposit derived var

* more routing

* Only display mortgage lender questions if mortgage is used
pull/1193/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
3d360d78a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/form/sales/pages/about_deposit_without_discount.rb
  2. 3
      app/models/form/sales/pages/mortgage_lender.rb
  3. 7
      app/models/form/sales/pages/mortgage_length.rb
  4. 5
      app/models/form/sales/questions/deposit_amount.rb
  5. 4
      spec/models/form/sales/pages/about_deposit_without_discount_spec.rb
  6. 4
      spec/models/form/sales/pages/mortgage_lender_spec.rb
  7. 4
      spec/models/form/sales/pages/mortgage_length_spec.rb
  8. 4
      spec/models/form/sales/questions/deposit_amount_spec.rb

4
app/models/form/sales/pages/about_deposit_without_discount.rb

@ -2,7 +2,9 @@ class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@header = "About the deposit" @header = "About the deposit"
@depends_on = [{ "is_type_discount?" => false }] @depends_on = [{ "is_type_discount?" => false, "ownershipsch" => 1 },
{ "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }]
end end
def questions def questions

3
app/models/form/sales/pages/mortgage_lender.rb

@ -4,6 +4,9 @@ class Form::Sales::Pages::MortgageLender < ::Form::Page
@header = "" @header = ""
@description = "" @description = ""
@subsection = subsection @subsection = subsection
@depends_on = [{
"mortgageused" => 1,
}]
end end
def questions def questions

7
app/models/form/sales/pages/mortgage_length.rb

@ -1,4 +1,11 @@
class Form::Sales::Pages::MortgageLength < ::Form::Page class Form::Sales::Pages::MortgageLength < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [{
"mortgageused" => 1,
}]
end
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::MortgageLength.new(nil, nil, self), Form::Sales::Questions::MortgageLength.new(nil, nil, self),

5
app/models/form/sales/questions/deposit_amount.rb

@ -9,5 +9,10 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question
@width = 5 @width = 5
@prefix = "£" @prefix = "£"
@hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage" @hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage"
@derived = true
end
def selected_answer_option_is_derived?(_log)
true
end end
end end

4
spec/models/form/sales/pages/about_deposit_without_discount_spec.rb

@ -29,7 +29,9 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => false }], [{ "is_type_discount?" => false, "ownershipsch" => 1 },
{ "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }],
) )
end end
end end

4
spec/models/form/sales/pages/mortgage_lender_spec.rb

@ -28,6 +28,8 @@ RSpec.describe Form::Sales::Pages::MortgageLender, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to be_nil expect(page.depends_on).to eq([{
"mortgageused" => 1,
}])
end end
end end

4
spec/models/form/sales/pages/mortgage_length_spec.rb

@ -28,6 +28,8 @@ RSpec.describe Form::Sales::Pages::MortgageLength, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to be_nil expect(page.depends_on).to eq([{
"mortgageused" => 1,
}])
end end
end end

4
spec/models/form/sales/questions/deposit_amount_spec.rb

@ -27,8 +27,8 @@ RSpec.describe Form::Sales::Questions::DepositAmount, type: :model do
expect(question.type).to eq("numeric") expect(question.type).to eq("numeric")
end end
it "is not marked as derived" do it "is marked as derived" do
expect(question.derived?).to be false expect(question.derived?).to be true
end end
it "has the correct hint" do it "has the correct hint" do

Loading…
Cancel
Save