Sha256: f4c203055e87dc682bb4e6d48855f6044d8f4a521e713027ee8921dfccaf6fe9

Contents?: true

Size: 1.12 KB

Versions: 91

Compression:

Stored size: 1.12 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 { generate(:sku) }
    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 }

    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_in_stock do
        after :create do |product|
          product.master.stock_items.first.adjust_count_on_hand(10)
        end
      end

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

Version data entries

91 entries across 91 versions & 2 rubygems

Version Path
spree_core-3.1.14 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.1.13 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.3.4 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.2.7 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.1.12 lib/spree/testing_support/factories/product_factory.rb
solidus_core-1.1.4 lib/spree/testing_support/factories/product_factory.rb
solidus_core-1.0.7 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.3.3 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.2.6 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.1.11 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.4.1 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.4.0 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.4.0.rc2 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.1.10 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.4.0.rc1 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.3.2 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.2.5 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.1.9 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.3.1 lib/spree/testing_support/factories/product_factory.rb
spree_core-3.2.4 lib/spree/testing_support/factories/product_factory.rb