mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-27 21:06:49 +00:00
11 lines
420 B
Ruby
11 lines
420 B
Ruby
# Initialise shipping method when created without one, like this:
|
|
# create(:product, :distributors => [...])
|
|
# In this case, we don't care what the shipping method is, but we need one for validations to pass.
|
|
ProductDistribution.class_eval do
|
|
before_validation :init_shipping_method
|
|
|
|
def init_shipping_method
|
|
self.shipping_method ||= Spree::ShippingMethod.first || FactoryGirl.create(:shipping_method)
|
|
end
|
|
end
|