Sha256: 21a7caedb5bfc427b62db367971d6a5c185402a35c404d11cb4d5f2151c0a8ee

Contents?: true

Size: 1.04 KB

Versions: 54

Compression:

Stored size: 1.04 KB

Contents

FactoryGirl.define do
  factory :stock_location, class: Spree::StockLocation do
    name 'NY Warehouse'
    address1 '1600 Pennsylvania Ave NW'
    city 'Washington'
    zipcode '20500'
    phone '(202) 456-1111'
    active true
    backorderable_default true

    country  { |stock_location| Spree::Country.first || stock_location.association(:country) }
    state do |stock_location|
      stock_location.country.states.first || stock_location.association(:state, country: stock_location.country)
    end

    factory :stock_location_with_items do
      after(:create) do |stock_location, evaluator|
        # variant will add itself to all stock_locations in an after_create
        # creating a product will automatically create a master variant
        product_1 = create(:product)
        product_2 = create(:product)

        stock_location.stock_items.where(variant_id: product_1.master.id).first.adjust_count_on_hand(10)
        stock_location.stock_items.where(variant_id: product_2.master.id).first.adjust_count_on_hand(20)
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

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