From f12eeaa58961bd57cd1d8f97c4d8120bb509921a Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Fri, 17 Mar 2023 09:55:44 +0000 Subject: [PATCH] feat: fix tests --- db/schema.rb | 2 +- .../sales/financial_validations_spec.rb | 28 ++++++++----------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 085419473..315152ef0 100644 --- a/db/schema.rb +++ b/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" diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index 78c9ed41a..abda71f7a 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/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