Sha256: 80b5324a5863b7706b070b6d1e68de6f7e9399dc38542ebddc5cc8b17b708248

Contents?: true

Size: 684 Bytes

Versions: 10

Compression:

Stored size: 684 Bytes

Contents

Factory.sequence(:product_sequence) {|n| "Product ##{n} - #{rand(9999)}"}

Factory.define :product do |f|
  f.name { Factory.next(:product_sequence) }
  f.description { Faker::Lorem.paragraphs(rand(5)+1).join("\n") }

  # associations:
  f.tax_category {|r| TaxCategory.find(:first) || r.association(:tax_category)}
  f.shipping_category {|r| ShippingCategory.find(:first) || r.association(:shipping_category)}

  f.price 19.99
  f.cost_price 17.00
  f.sku "ABC"
  f.available_on { 1.year.ago }
  f.deleted_at nil
end

Factory.define :product_with_option_types, :parent => :product do |f|
  f.after_create do |product|
    Factory(:product_option_type, :product => product)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_core-0.70.7 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.6 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.5 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.4 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.3 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.2 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.1 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.0 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.0.rc2 lib/spree_core/testing_support/factories/product_factory.rb
spree_core-0.70.RC1 lib/spree_core/testing_support/factories/product_factory.rb