Sha256: b8b1b92a050b77aca46e070e5cbbe264e58d45b2ddb0897a3e1df66dc3026419

Contents?: true

Size: 1.04 KB

Versions: 30

Compression:

Stored size: 1.04 KB

Contents

FactoryGirl.define do
  factory :base_product, class: Spree::Product do
    sequence(:name) { |n| "Product ##{n} - #{Kernel.rand(9999)}" }
    description { generate(:random_description) }
    price 19.99
    cost_price 17.00
    sku 'ABC'
    available_on { 1.year.ago }
    deleted_at nil
    shipping_category { |r| Spree::ShippingCategory.first || r.association(:shipping_category) }

    # ensure stock item will be created for this products master
    before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 }

    after(:create) do |p|
      p.variants_including_master.each { |v| v.save! }
    end

    factory :custom_product do
      name 'Custom Product'
      price 17.99

      tax_category { |r| Spree::TaxCategory.first || r.association(:tax_category) }
    end

    factory :product do
      tax_category { |r| Spree::TaxCategory.first || r.association(:tax_category) }

      factory :product_with_option_types do
        after(:create) { |product| create(:product_option_type, product: product) }
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
spree_core-2.2.14 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.13 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.12 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.11 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.10 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.9 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.1.12 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.8 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.1.11 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.7 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.1.10 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.0.13 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.1.9 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.6 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.5 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.1.8 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.0.12 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.4 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.3 lib/spree/testing_support/factories/product_factory.rb
spree_core-2.2.2 lib/spree/testing_support/factories/product_factory.rb