Browse Source

feat: fix tests

pull/1400/head
natdeanlewissoftwire 3 years ago
parent
commit
f12eeaa589
  1. 2
      db/schema.rb
  2. 28
      spec/models/validations/sales/financial_validations_spec.rb

2
db/schema.rb

@ -541,9 +541,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_08_101826) do
t.integer "ethnicbuy2" t.integer "ethnicbuy2"
t.integer "proplen_asked" t.integer "proplen_asked"
t.string "old_id" t.string "old_id"
t.integer "pregblank"
t.integer "buy2living" t.integer "buy2living"
t.integer "prevtenbuy2" t.integer "prevtenbuy2"
t.integer "pregblank"
t.integer "nationalbuy2" t.integer "nationalbuy2"
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"

28
spec/models/validations/sales/financial_validations_spec.rb

@ -268,17 +268,18 @@ RSpec.describe Validations::Sales::FinancialValidations do
end end
describe "#validate_equity_in_range_for_year_and_type" do describe "#validate_equity_in_range_for_year_and_type" do
let(:record) { FactoryBot.create(:sales_log) } let(:record) { FactoryBot.create(:sales_log, saledate: now) }
context "with a log in the 22/23 collection year" do before do
before do Timecop.freeze(now)
Timecop.freeze(Time.zone.local(2023, 1, 1)) end
record.update!(saledate: Time.zone.local(2023, 1, 1))
end
after do after do
Timecop.unfreeze Timecop.unfreeze
end end
context "with a log in the 22/23 collection year" do
let(:now) { Time.zone.local(2023, 1, 1) }
it "adds an error for type 2, equity below min with the correct percentage" do it "adds an error for type 2, equity below min with the correct percentage" do
record.type = 2 record.type = 2
@ -313,14 +314,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
end end
context "with a log in 23/24 collection year" do context "with a log in 23/24 collection year" do
before do let(:now) { Time.zone.local(2024, 1, 1) }
Timecop.freeze(Time.zone.local(2024, 1, 1))
record.update!(saledate: Time.zone.local(2024, 1, 1))
end
after do
Timecop.unfreeze
end
it "adds an error for type 2, equity below min with the correct percentage" do it "adds an error for type 2, equity below min with the correct percentage" do
record.type = 2 record.type = 2

Loading…
Cancel
Save