Browse Source

feat: add validation condition and update tests

pull/1201/head
natdeanlewissoftwire 3 years ago
parent
commit
5898912b29
  1. 4
      app/models/validations/sales/soft_validations.rb
  2. 1
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
  3. 1
      spec/models/form/sales/subsections/outright_sale_spec.rb
  4. 1
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
  5. 4
      spec/models/form_handler_spec.rb

4
app/models/validations/sales/soft_validations.rb

@ -38,6 +38,8 @@ module Validations::Sales::SoftValidations
end end
def extra_borrowing_expected? def extra_borrowing_expected?
true return unless extrabor && mortgage && deposit && value && cashdis
mortgage + deposit > value - value * discount / 100
end end
end end

1
spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb

@ -24,6 +24,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
mortgage_lender_other_discounted_ownership mortgage_lender_other_discounted_ownership
mortgage_length_discounted_ownership mortgage_length_discounted_ownership
extra_borrowing_discounted_ownership extra_borrowing_discounted_ownership
extra_borrowing_value_check_discounted_ownership
about_deposit_discounted_ownership about_deposit_discounted_ownership
discounted_ownership_deposit_value_check discounted_ownership_deposit_value_check
leasehold_charges_discounted_ownership leasehold_charges_discounted_ownership

1
spec/models/form/sales/subsections/outright_sale_spec.rb

@ -21,6 +21,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
mortgage_lender_other_outright_sale mortgage_lender_other_outright_sale
mortgage_length_outright_sale mortgage_length_outright_sale
extra_borrowing_outright_sale extra_borrowing_outright_sale
extra_borrowing_value_check_outright_sale
about_deposit_outright_sale about_deposit_outright_sale
outright_sale_deposit_value_check outright_sale_deposit_value_check
leasehold_charges_outright_sale leasehold_charges_outright_sale

1
spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

@ -32,6 +32,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
mortgage_lender_other_shared_ownership mortgage_lender_other_shared_ownership
mortgage_length_shared_ownership mortgage_length_shared_ownership
extra_borrowing_shared_ownership extra_borrowing_shared_ownership
extra_borrowing_value_check_shared_ownership
about_deposit_with_discount about_deposit_with_discount
about_deposit_shared_ownership about_deposit_shared_ownership
shared_ownership_deposit_value_check shared_ownership_deposit_value_check

4
spec/models/form_handler_spec.rb

@ -52,14 +52,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do it "is able to load a current sales form" do
form = form_handler.get_form("current_sales") form = form_handler.get_form("current_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(148) expect(form.pages.count).to eq(151)
expect(form.name).to eq("2022_2023_sales") expect(form.name).to eq("2022_2023_sales")
end end
it "is able to load a previous sales form" do it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales") form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(148) expect(form.pages.count).to eq(151)
expect(form.name).to eq("2021_2022_sales") expect(form.name).to eq("2021_2022_sales")
end end
end end

Loading…
Cancel
Save