Update factories and tests

This commit is contained in:
Matt-Yorkley
2023-08-07 14:45:26 +01:00
parent a93809b75f
commit 3898af2c37
3 changed files with 7 additions and 24 deletions

View File

@@ -7,9 +7,6 @@ FactoryBot.define do
sequence(:random_description) { FFaker::Lorem.paragraphs(Kernel.rand(1..5)).join("\n") }
sequence(:random_email) { FFaker::Internet.email }
factory :classification, class: Spree::Classification do
end
factory :exchange, class: Exchange do
incoming { false }
order_cycle { OrderCycle.first || FactoryBot.create(:simple_order_cycle) }

View File

@@ -7,11 +7,11 @@ describe Enterprise do
describe "is touched when a(n)" do
let(:enterprise) { create(:distributor_enterprise) }
let(:taxon) { create(:taxon) }
let(:taxon2) { create(:taxon) }
let(:supplier2) { create(:supplier_enterprise) }
describe "with a supplied product" do
let(:product) { create(:simple_product, supplier: enterprise) }
let!(:classification) { create(:classification, taxon: taxon, product: product) }
let(:product) { create(:simple_product, supplier: enterprise, primary_taxon_id: taxon.id) }
let(:property) { product.product_properties.last }
let(:producer_property) { enterprise.producer_properties.last }
@@ -20,9 +20,9 @@ describe Enterprise do
enterprise.set_producer_property 'Biodynamic', 'ASDF 4321'
end
it "touches enterprise when a classification on that product changes" do
it "touches enterprise when a taxon on that product changes" do
expect {
later { classification.touch }
later { product.update(primary_taxon_id: taxon2.id) }
}.to change { enterprise.reload.updated_at }
end
@@ -46,13 +46,12 @@ describe Enterprise do
end
describe "with a distributed product" do
let(:product) { create(:simple_product) }
let(:product) { create(:simple_product, primary_taxon_id: taxon.id) }
let(:oc) {
create(:simple_order_cycle, distributors: [enterprise],
variants: [product.variants.first])
}
let(:supplier) { product.supplier }
let!(:classification) { create(:classification, taxon: taxon, product: product) }
let(:property) { product.product_properties.last }
let(:producer_property) { supplier.producer_properties.last }
@@ -64,9 +63,9 @@ describe Enterprise do
context "with an order cycle" do
before { oc }
it "touches enterprise when a classification on that product changes" do
it "touches enterprise when a taxon on that product changes" do
expect {
later { classification.touch }
later { product.update(primary_taxon_id: taxon2.id) }
}.to change { enterprise.reload.updated_at }
end

View File

@@ -140,19 +140,6 @@ module Spree
end
end
# Regression tests for Spree #2352
context "classifications and taxons" do
it "is joined through classifications" do
reflection = Spree::Product.reflect_on_association(:taxons)
reflection.options[:through] = :classifications
end
it "will delete all classifications" do
reflection = Spree::Product.reflect_on_association(:classifications)
reflection.options[:dependent] = :delete_all
end
end
describe '#total_on_hand' do
it 'returns sum of stock items count_on_hand' do
product = build(:product)