Sha256: ac94ec3aaa719ac17d4b7c0cd26492fbf991ee6a4d713a1a030cf839578d7ade

Contents?: true

Size: 958 Bytes

Versions: 68

Compression:

Stored size: 958 Bytes

Contents

FactoryGirl.define do
  sequence(:random_float) { BigDecimal.new("#{rand(200)}.#{rand(99)}") }

  factory :base_variant, class: Spree::Variant do
    price 19.99
    cost_price 17.00
    sku    { generate(:sku) }
    weight { generate(:random_float) }
    height { generate(:random_float) }
    width  { generate(:random_float) }
    depth  { generate(:random_float) }
    is_master 0
    track_inventory true

    product { |p| p.association(:base_product) }
    option_values { [create(:option_value)] }

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

    factory :variant do
      # on_hand 5
      product { |p| p.association(:product) }
    end

    factory :master_variant do
      is_master 1
    end

    factory :on_demand_variant do
      track_inventory false

      factory :on_demand_master_variant do
        is_master 1
      end
    end

  end
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
spree_core-3.1.14 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.13 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.4 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.2.7 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.12 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.3 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.2.6 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.11 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.10 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.2 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.2.5 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.9 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.1 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.2.4 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.8 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.0 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.0.rc4 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.3.0.rc3 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.1.7 lib/spree/testing_support/factories/variant_factory.rb
spree_core-3.2.3 lib/spree/testing_support/factories/variant_factory.rb