mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Bring shipping_method factory from spree_core and merge with modification
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
FactoryBot.define do
|
||||
factory :base_shipping_method, class: Spree::ShippingMethod do
|
||||
zones { [] }
|
||||
name 'UPS Ground'
|
||||
|
||||
distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] }
|
||||
display_on ''
|
||||
|
||||
before(:create) do |shipping_method, evaluator|
|
||||
shipping_method.shipping_categories << (Spree::ShippingCategory.first || create(:shipping_category))
|
||||
end
|
||||
|
||||
trait :flat_rate do
|
||||
transient { amount 1 }
|
||||
calculator { build(:calculator_flat_rate, preferred_amount: amount) }
|
||||
end
|
||||
|
||||
trait :per_item do
|
||||
transient { amount 1 }
|
||||
calculator { build(:calculator_per_item, preferred_amount: amount) }
|
||||
end
|
||||
|
||||
factory :shipping_method, class: Spree::ShippingMethod do
|
||||
association(:calculator, factory: :calculator, strategy: :build)
|
||||
end
|
||||
|
||||
factory :free_shipping_method, class: Spree::ShippingMethod do
|
||||
association(:calculator, factory: :no_amount_calculator, strategy: :build)
|
||||
end
|
||||
end
|
||||
|
||||
factory :shipping_method_with, parent: :shipping_method do
|
||||
trait :delivery do
|
||||
require_ship_address { true }
|
||||
@@ -36,21 +66,3 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
FactoryBot.modify do
|
||||
factory :shipping_method, parent: :base_shipping_method do
|
||||
distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] }
|
||||
display_on ''
|
||||
zones { [] }
|
||||
|
||||
trait :flat_rate do
|
||||
transient { amount 1 }
|
||||
calculator { build(:calculator_flat_rate, preferred_amount: amount) }
|
||||
end
|
||||
|
||||
trait :per_item do
|
||||
transient { amount 1 }
|
||||
calculator { build(:calculator_per_item, preferred_amount: amount) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user