Browse Source

Update some tests for 2023 collection close

pull/2445/head
Kat 2 years ago
parent
commit
c7243c9976
  1. 4
      spec/models/form/lettings/questions/stock_owner_spec.rb
  2. 12
      spec/models/validations/sales/setup_validations_spec.rb

4
spec/models/form/lettings/questions/stock_owner_spec.rb

@ -51,7 +51,7 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do
let!(:org_rel) do
create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: owning_org_2)
end
let(:log) { create(:lettings_log, owning_organisation: owning_org_1) }
let(:log) { build(:lettings_log, owning_organisation: owning_org_1) }
context "when user's org owns stock" do
let(:options) do
@ -201,7 +201,7 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do
context "when user is support" do
let!(:user) { create(:user, :support) }
let!(:log) { create(:lettings_log) }
let!(:log) { build(:lettings_log) }
it "shows active orgs where organisation holds own stock" do
non_stock_organisation = create(:organisation, name: "Non-stockholding org", holds_own_stock: false)

12
spec/models/validations/sales/setup_validations_spec.rb

@ -74,6 +74,10 @@ RSpec.describe Validations::Sales::SetupValidations do
context "when saledate is in the 22/23 collection year" do
let(:record) { build(:sales_log, saledate: Time.zone.local(2024, 1, 1)) }
before do
allow(FormHandler.instance).to receive(:sales_in_crossover_period?).and_return(true)
end
it "does not add an error" do
setup_validator.validate_saledate_collection_year(record)
@ -84,6 +88,10 @@ RSpec.describe Validations::Sales::SetupValidations do
context "when saledate is before the 22/23 collection year" do
let(:record) { build(:sales_log, saledate: Time.zone.local(2020, 5, 1)) }
before do
allow(FormHandler.instance).to receive(:sales_in_crossover_period?).and_return(true)
end
it "adds error" do
setup_validator.validate_saledate_collection_year(record)
@ -94,6 +102,10 @@ RSpec.describe Validations::Sales::SetupValidations do
context "when saledate is after the 22/23 collection year" do
let(:record) { build(:sales_log, saledate: Time.zone.local(2025, 4, 1)) }
before do
allow(FormHandler.instance).to receive(:sales_in_crossover_period?).and_return(true)
end
it "adds error" do
setup_validator.validate_saledate_collection_year(record)

Loading…
Cancel
Save