mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Touch ShippingMethod when it's assigned to a new distributor
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class DistributorShippingMethod < ActiveRecord::Base
|
||||
self.table_name = "distributors_shipping_methods"
|
||||
belongs_to :shipping_method, class_name: Spree::ShippingMethod
|
||||
belongs_to :shipping_method, class_name: Spree::ShippingMethod, touch: true
|
||||
belongs_to :distributor, class_name: Enterprise, touch: true
|
||||
end
|
||||
|
||||
@@ -109,5 +109,15 @@ module Spree
|
||||
expect(shipping_method.include?(address)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "touches" do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:shipping_method) { create(:shipping_method) }
|
||||
let(:add_distributor) { shipping_method.distributors << distributor }
|
||||
|
||||
it "is touched when applied to a distributor" do
|
||||
expect{ add_distributor }.to change { shipping_method.reload.updated_at}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user