Browse Source

Further test updates to support passing log to derived?

pull/2354/head
Robert Sullivan 2 years ago
parent
commit
e5d011e3d9
  1. 2
      spec/models/form/lettings/questions/location_id_spec.rb
  2. 2
      spec/models/form/lettings/questions/needs_type_spec.rb
  3. 2
      spec/models/form/lettings/questions/reason_renewal_spec.rb
  4. 2
      spec/models/form/lettings/questions/reason_spec.rb
  5. 2
      spec/models/form/lettings/questions/voiddate_spec.rb
  6. 29
      spec/models/sales_log_spec.rb

2
spec/models/form/lettings/questions/location_id_spec.rb

@ -36,7 +36,7 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do
end
it "is marked as derived" do
expect(question).not_to be_derived
expect(question).not_to be_derived(nil)
end
context "when there are no locations" do

2
spec/models/form/lettings/questions/needs_type_spec.rb

@ -28,7 +28,7 @@ RSpec.describe Form::Lettings::Questions::NeedsType, type: :model do
end
it "is not marked as derived" do
expect(question).not_to be_derived
expect(question).not_to be_derived(nil)
end
it "has the correct answer_options" do

2
spec/models/form/lettings/questions/reason_renewal_spec.rb

@ -48,7 +48,7 @@ RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do
end
it "is not marked as derived" do
expect(question).not_to be_derived
expect(question).not_to be_derived(nil)
end
context "with 2023/24 form" do

2
spec/models/form/lettings/questions/reason_spec.rb

@ -44,7 +44,7 @@ RSpec.describe Form::Lettings::Questions::Reason, type: :model do
end
it "is not marked as derived" do
expect(question).not_to be_derived
expect(question).not_to be_derived(nil)
end
context "with 2023/24 form" do

2
spec/models/form/lettings/questions/voiddate_spec.rb

@ -40,6 +40,6 @@ RSpec.describe Form::Lettings::Questions::Voiddate, type: :model do
end
it "is not marked as derived" do
expect(question).not_to be_derived
expect(question).not_to be_derived(nil)
end
end

29
spec/models/sales_log_spec.rb

@ -584,13 +584,6 @@ RSpec.describe SalesLog, type: :model do
expect(record_from_db["deposit"]).to eq(nil)
end
it "does not clear deposit when setting mortgage used to yes from no for outright sales with new deposit value" do
sales_log.update!(value: 123_400, deposit: nil, mortgageused: 2, ownershipsch: 3, type: 10, companybuy: 1, jointpur: 1, jointmore: 1)
sales_log.update!(mortgageused: 1, deposit: 1000)
record_from_db = described_class.find(sales_log.id)
expect(record_from_db["deposit"]).to eq(1000)
end
it "clears deposit when changing from outright sale with no mortgage to shared ownership" do
sales_log.update!(value: 123_400, deposit: nil, mortgageused: 2, ownershipsch: 3, type: 10, companybuy: 1, jointpur: 1, jointmore: 1)
sales_log.update!(ownershipsch: 1)
@ -606,21 +599,6 @@ RSpec.describe SalesLog, type: :model do
expect(record_from_db["deposit"]).to eq(nil)
end
it "does not clear deposit when changing from outright sale with no mortgage to shared ownership with new deposit value" do
sales_log.update!(value: 123_400, deposit: nil, mortgageused: 2, ownershipsch: 3, type: 10, companybuy: 1, jointpur: 1, jointmore: 1)
sales_log.update!(ownershipsch: 1, deposit: 1000)
record_from_db = described_class.find(sales_log.id)
expect(record_from_db["deposit"]).to eq(1000)
end
it "does not clear when changing from outright sale with no mortgage to discounted ownership with new deposit value" do
Timecop.freeze(2024, 5, 2)
sales_log.update!(value: 123_400, deposit: nil, mortgageused: 2, ownershipsch: 3, type: 10, companybuy: 1, jointpur: 1, jointmore: 1)
sales_log.update!(ownershipsch: 2, deposit: 1000)
record_from_db = described_class.find(sales_log.id)
expect(record_from_db["deposit"]).to eq(1000)
end
it "correctly derives and saves pcode1 and pcode1 and pcode2" do
sales_log.update!(postcode_full: "W6 0SP")
record_from_db = described_class.find(sales_log.id)
@ -636,13 +614,6 @@ RSpec.describe SalesLog, type: :model do
expect(record_from_db["mortgage"]).to eq(0.0)
end
it "derives a mortgage value of 0 when mortgage is unknown" do
Timecop.freeze(2024, 5, 2)
sales_log.update!(value: 123_400, saledate: Time.zone.local(2024, 5, 2), mortgageused: 3, ownershipsch: 3, type: 10, companybuy: 1, jointpur: 1, jointmore: 1)
record_from_db = described_class.find(sales_log.id)
expect(record_from_db["mortgage"]).to eq(0.0)
end
it "clears mortgage value if mortgage used is changed from no to yes" do
# to avoid log failing validations when mortgage value is removed:
new_grant_value = sales_log.grant + sales_log.mortgage

Loading…
Cancel
Save