Browse Source

feat: add tests

pull/1201/head
natdeanlewissoftwire 3 years ago
parent
commit
0ca546b50c
  1. 12
      db/schema.rb
  2. 83
      spec/models/validations/sales/soft_validations_spec.rb

12
db/schema.rb

@ -485,19 +485,19 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_18_170602) do
t.integer "hoyear"
t.integer "fromprop"
t.integer "socprevten"
t.integer "mortlen"
t.integer "mortgagelender"
t.string "mortgagelenderother"
t.integer "extrabor"
t.integer "hhmemb"
t.integer "totadult"
t.integer "totchild"
t.integer "hhtype"
t.integer "mortlen"
t.string "pcode1"
t.string "pcode2"
t.integer "pcodenk"
t.string "postcode_full"
t.boolean "is_la_inferred"
t.integer "extrabor"
t.integer "hhmemb"
t.integer "totadult"
t.integer "totchild"
t.integer "hhtype"
t.integer "extrabor_value_check"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"

83
spec/models/validations/sales/soft_validations_spec.rb

@ -128,7 +128,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.not_to be_mortgage_over_soft_max
end
it "returns true if only income1 is used for morgage and it is less than 1/5 of the morgage" do
it "returns true if only income1 is used for mortgage and it is less than 1/5 of the mortgage" do
record.inc1mort = 1
record.income1 = 10_000
record.mortgage = 51_000
@ -137,7 +137,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.to be_mortgage_over_soft_max
end
it "returns false if only income1 is used for morgage and it is more than 1/5 of the morgage" do
it "returns false if only income1 is used for mortgage and it is more than 1/5 of the mortgage" do
record.inc1mort = 1
record.income1 = 10_000
record.mortgage = 44_000
@ -146,7 +146,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.not_to be_mortgage_over_soft_max
end
it "returns true if only income2 is used for morgage and it is less than 1/5 of the morgage" do
it "returns true if only income2 is used for mortgage and it is less than 1/5 of the mortgage" do
record.inc1mort = 2
record.inc2mort = 1
record.income2 = 10_000
@ -155,7 +155,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.to be_mortgage_over_soft_max
end
it "returns false if only income2 is used for morgage and it is more than 1/5 of the morgage" do
it "returns false if only income2 is used for mortgage and it is more than 1/5 of the mortgage" do
record.inc1mort = 2
record.inc2mort = 1
record.income2 = 10_000
@ -164,7 +164,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.not_to be_mortgage_over_soft_max
end
it "returns true if income1 and income2 are used for morgage and their sum is less than 1/5 of the morgage" do
it "returns true if income1 and income2 are used for mortgage and their sum is less than 1/5 of the mortgage" do
record.inc1mort = 1
record.inc2mort = 1
record.income1 = 10_000
@ -174,7 +174,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.to be_mortgage_over_soft_max
end
it "returns false if income1 and income2 are used for morgage and their sum is more than 1/5 of the morgage" do
it "returns false if income1 and income2 are used for mortgage and their sum is more than 1/5 of the mortgage" do
record.inc1mort = 1
record.inc2mort = 1
record.income1 = 8_000
@ -184,7 +184,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.not_to be_mortgage_over_soft_max
end
it "returns true if neither of the incomes are used for morgage and the morgage is more than 0" do
it "returns true if neither of the incomes are used for mortgage and the mortgage is more than 0" do
record.inc1mort = 2
record.inc2mort = 2
record.mortgage = 124_000
@ -192,7 +192,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.to be_mortgage_over_soft_max
end
it "returns true if neither of the incomes are used for morgage and the morgage is 0" do
it "returns false if neither of the incomes are used for mortgage and the mortgage is 0" do
record.inc1mort = 2
record.inc2mort = 2
record.mortgage = 0
@ -200,6 +200,73 @@ RSpec.describe Validations::Sales::SoftValidations do
.not_to be_mortgage_over_soft_max
end
end
context "when validating extra borrowing" do
it "returns false if extrabor not present" do
record.mortgage = 50_000
record.deposit = 40_000
record.value = 100_000
record.discount = 11
expect(record)
.not_to be_extra_borrowing_expected_but_not_reported
end
it "returns false if deposit not present" do
record.extrabor = 2
record.deposit = 40_000
record.value = 100_000
record.discount = 11
expect(record)
.not_to be_extra_borrowing_expected_but_not_reported
end
it "returns false if deposit not present" do
record.extrabor = 2
record.mortgage = 50_000
record.value = 100_000
record.discount = 11
expect(record)
.not_to be_extra_borrowing_expected_but_not_reported
end
it "returns false if value not present" do
record.extrabor = 2
record.mortgage = 50_000
record.deposit = 40_000
record.discount = 11
expect(record)
.not_to be_extra_borrowing_expected_but_not_reported
end
it "returns false if discount not present" do
record.extrabor = 2
record.mortgage = 50_000
record.deposit = 40_000
record.value = 100_000
expect(record)
.not_to be_extra_borrowing_expected_but_not_reported
end
it "returns false if extra borrowing expected and reported" do
record.extrabor = 1
record.mortgage = 50_000
record.deposit = 40_000
record.value = 100_000
record.discount = 11
expect(record)
.not_to be_extra_borrowing_expected_but_not_reported
end
it "returns true if extra borrowing expected but not reported" do
record.extrabor = 2
record.mortgage = 50_000
record.deposit = 40_000
record.value = 100_000
record.discount = 11
expect(record)
.to be_extra_borrowing_expected_but_not_reported
end
end
end
describe "savings amount validations" do

Loading…
Cancel
Save