Sha256: 219744691c92e089629fddbdc47b1f4faeee47b65fead017dbe3a2c93759fe69

Contents?: true

Size: 1.13 KB

Versions: 32

Compression:

Stored size: 1.13 KB

Contents

require 'spree/testing_support/factories/calculator_factory'
require 'spree/testing_support/factories/shipping_category_factory'
require 'spree/testing_support/factories/zone_factory'

FactoryGirl.define do
  factory(
    :shipping_method,
    aliases: [
      :base_shipping_method
    ],
    class: Spree::ShippingMethod
  ) do
    zones do
      [Spree::Zone.find_by(name: 'GlobalZone') || FactoryGirl.create(:global_zone)]
    end

    name 'UPS Ground'
    code 'UPS_GROUND'
    carrier 'UPS'
    service_level '1DAYGROUND'

    calculator { |s| s.association(:shipping_calculator, strategy: :build, preferred_amount: s.cost, preferred_currency: s.currency) }

    transient do
      cost 10.0
      currency 'USD'
    end

    before(:create) do |shipping_method, _evaluator|
      if shipping_method.shipping_categories.empty?
        shipping_method.shipping_categories << (Spree::ShippingCategory.first || create(:shipping_category))
      end
    end

    factory :free_shipping_method, class: Spree::ShippingMethod do
      cost nil
      association(:calculator, factory: :shipping_no_amount_calculator, strategy: :build)
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
solidus_core-2.3.1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.2.2 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.1.1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.0.3 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-1.4.2 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-1.3.2 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.3.0 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.3.0.rc3 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.3.0.rc2 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.3.0.rc1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.3.0.beta1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.0.2 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-1.4.1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.2.1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.2.0 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.2.0.rc1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.2.0.beta1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.1.0 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.1.0.rc1 lib/spree/testing_support/factories/shipping_method_factory.rb
solidus_core-2.0.1 lib/spree/testing_support/factories/shipping_method_factory.rb