Skip to content

Commit

Permalink
Fix factory issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Yorkley committed Aug 7, 2023
1 parent 4a90100 commit 9ff70b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/factories/product_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
deleted_at { nil }

supplier { Enterprise.is_primary_producer.first || FactoryBot.create(:supplier_enterprise) }
primary_taxon { Spree::Taxon.first || FactoryBot.create(:taxon) }
primary_taxon_id { (Spree::Taxon.first || FactoryBot.create(:taxon)).id }

unit_value { 1 }
unit_description { '' }
Expand Down
5 changes: 3 additions & 2 deletions spec/factories/variant_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
width { generate(:random_float) }
depth { generate(:random_float) }

product { |p| p.association(:base_product) }
primary_taxon { Spree::Taxon.first || FactoryBot.create(:taxon) }
product { |v| create(:product, primary_taxon_id: v.primary_taxon.id) }

# ensure stock item will be created for this variant
before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? }
Expand All @@ -22,7 +23,7 @@
on_hand { 5 }
end

product { |p| p.association(:product) }
product { |v| create(:product, primary_taxon_id: v.primary_taxon.id) }
unit_value { 1 }
unit_description { '' }

Expand Down

0 comments on commit 9ff70b5

Please sign in to comment.