diff --git a/app/models/form/sales/pages/about_deposit_with_discount.rb b/app/models/form/sales/pages/about_deposit_with_discount.rb index bf3b38224..1de5365aa 100644 --- a/app/models/form/sales/pages/about_deposit_with_discount.rb +++ b/app/models/form/sales/pages/about_deposit_with_discount.rb @@ -5,7 +5,7 @@ class Form::Sales::Pages::AboutDepositWithDiscount < ::Form::Page @header = "About the deposit" @description = "" @subsection = subsection - @depends_on = [{ "type" => 18 }] + @depends_on = [{ "is_type_discount?" => true }] end def questions diff --git a/app/models/form/sales/pages/about_deposit_without_discount.rb b/app/models/form/sales/pages/about_deposit_without_discount.rb index 7a0dbcfa3..32e8868dd 100644 --- a/app/models/form/sales/pages/about_deposit_without_discount.rb +++ b/app/models/form/sales/pages/about_deposit_without_discount.rb @@ -4,23 +4,8 @@ class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page @header = "About the deposit" @description = "" @subsection = subsection - @depends_on = [ - { "type" => 2 }, - { "type" => 24 }, - { "type" => 16 }, - { "type" => 28 }, - { "type" => 31 }, - { "type" => 30 }, - { "type" => 8 }, - { "type" => 14 }, - { "type" => 27 }, - { "type" => 9 }, - { "type" => 29 }, - { "type" => 21 }, - { "type" => 22 }, - { "type" => 10 }, - { "type" => 12 }, - ] + @depends_on = [{ "is_type_discount?" => false }] + end def questions diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index cda76d10e..65175a802 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -115,4 +115,8 @@ class SalesLog < Log def right_to_buy? [9, 14, 27].include?(type) end + + def is_type_discount? + type == 18 + end end diff --git a/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb b/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb index 4842d3286..692f17a75 100644 --- a/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb +++ b/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb @@ -29,9 +29,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq( - [ - { "type" => 18 }, - ], + [{ "is_type_discount?" => true }], ) end end diff --git a/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb b/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb index f6f0c321f..07f9c983d 100644 --- a/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb +++ b/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb @@ -29,23 +29,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq( - [ - { "type" => 2 }, - { "type" => 24 }, - { "type" => 16 }, - { "type" => 28 }, - { "type" => 31 }, - { "type" => 30 }, - { "type" => 8 }, - { "type" => 14 }, - { "type" => 27 }, - { "type" => 9 }, - { "type" => 29 }, - { "type" => 21 }, - { "type" => 22 }, - { "type" => 10 }, - { "type" => 12 }, - ], + [{ "is_type_discount?" => false }], ) end end