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 "proplen_asked"
t.string "old_id"
t.integer "pregblank"
t.integer "buy2living"
t.integer "prevtenbuy2"
t.integer "pregblank"
t.integer "nationalbuy2"
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"

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

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

Loading…
Cancel
Save