Sha256: f3cc7a30cebacdd49d66bc23cb7ab15740afd590ce8d8e7c77d0e2734d0dc5d8

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

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

  factory :product, :class => Spree::Product do
    name { Factory.next :product_sequence }
    description { Faker::Lorem.paragraphs(rand(5)+1).join("\n") }

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

    price 19.99
    cost_price 17.00
    sku 'ABC'
    available_on 1.year.ago
    deleted_at nil
  end

  factory :product_with_option_types, :parent => :product do
    after_create { |product| Factory(:product_option_type, :product => product) }
  end

  factory :custom_product, :class => Spree::Product do
    name "Custom Product"
    price "17.99"
    description { Faker::Lorem.paragraphs(rand(5)+1).join("\n") }

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

    sku 'ABC'
    available_on 1.year.ago
    deleted_at nil

    association :taxons
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spree_core-1.0.7 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.6 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.4 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.3 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.2 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.1 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.0 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.0.rc4 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.0.rc3 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.0.rc2 lib/spree/core/testing_support/factories/product_factory.rb
spree_core-1.0.0.rc1 lib/spree/core/testing_support/factories/product_factory.rb