From 6d9250c014dd0b8f28afb8f7c49a3e7e2e7ef1c1 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sun, 23 Aug 2020 14:15:20 +0100 Subject: [PATCH] Bring tax category factory from spree_core and fix a problem with the stock location of the product factory --- spec/factories.rb | 1 + spec/factories/product_factory.rb | 2 +- spec/factories/tax_category_factory.rb | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 spec/factories/tax_category_factory.rb diff --git a/spec/factories.rb b/spec/factories.rb index 50c2a64b5d..94017b374e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,6 +1,7 @@ require 'ffaker' FactoryBot.define do + sequence(:random_string) { Faker::Lorem.sentence } sequence(:random_description) { Faker::Lorem.paragraphs(1 + Kernel.rand(5)).join("\n") } sequence(:random_email) { Faker::Internet.email } diff --git a/spec/factories/product_factory.rb b/spec/factories/product_factory.rb index f13cad00ba..bf19b0717a 100644 --- a/spec/factories/product_factory.rb +++ b/spec/factories/product_factory.rb @@ -21,7 +21,7 @@ FactoryBot.define do shipping_category { DefaultShippingCategory.find_or_create } # ensure stock item will be created for this products master - before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 } + before(:create) { DefaultStockLocation.find_or_create } factory :product do transient do diff --git a/spec/factories/tax_category_factory.rb b/spec/factories/tax_category_factory.rb new file mode 100644 index 0000000000..6419bb9574 --- /dev/null +++ b/spec/factories/tax_category_factory.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :tax_category, class: Spree::TaxCategory do + name { "TaxCategory - #{rand(999999)}" } + description { generate(:random_string) } + end +end