Sha256: 098bfc1caa135ffdc2b5ec8cb32fe6506429221635a44f4c730b1ce0dadda4f0

Contents?: true

Size: 1 KB

Versions: 26

Compression:

Stored size: 1 KB

Contents

require 'spree/testing_support/sequences'
require 'spree/testing_support/factories/option_value_factory'
require 'spree/testing_support/factories/option_type_factory'
require 'spree/testing_support/factories/product_factory'

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) }
    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

26 entries across 26 versions & 1 rubygems

Version Path
solidus_core-2.2.2 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.1.1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.0.3 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-1.4.2 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-1.3.2 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.0.2 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-1.4.1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.2.1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.2.0 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.2.0.rc1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.2.0.beta1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.1.0 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.1.0.rc1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.0.1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.1.0.beta1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.0.0 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-1.4.0 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.0.0.rc1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-1.4.0.rc1 lib/spree/testing_support/factories/variant_factory.rb
solidus_core-2.0.0.beta1 lib/spree/testing_support/factories/variant_factory.rb