mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add enterprise cache invalidation for order cycle changes
This commit is contained in:
@@ -3,7 +3,7 @@ class Exchange < ActiveRecord::Base
|
||||
|
||||
belongs_to :order_cycle
|
||||
belongs_to :sender, class_name: 'Enterprise'
|
||||
belongs_to :receiver, class_name: 'Enterprise'
|
||||
belongs_to :receiver, class_name: 'Enterprise', touch: true
|
||||
belongs_to :payment_enterprise, class_name: 'Enterprise'
|
||||
|
||||
has_many :exchange_variants, dependent: :destroy
|
||||
|
||||
@@ -17,12 +17,17 @@ describe Enterprise do
|
||||
|
||||
describe "with a distributed product" do
|
||||
let(:product) { create(:simple_product) }
|
||||
let!(:oc) { create(:simple_order_cycle, distributors: [enterprise], variants: [product.master]) }
|
||||
let(:oc) { create(:simple_order_cycle, distributors: [enterprise], variants: [product.variants.first]) }
|
||||
let!(:classification) { create(:classification, taxon: taxon, product: product) }
|
||||
|
||||
it "touches enterprise when a classification on that product changes" do
|
||||
oc
|
||||
expect { classification.save! }.to change { enterprise.reload.updated_at }
|
||||
end
|
||||
|
||||
it "touches enterprise when the product's variant is added to order cycle" do
|
||||
expect { oc }.to change { enterprise.reload.updated_at }
|
||||
end
|
||||
end
|
||||
|
||||
describe "with relatives" do
|
||||
|
||||
Reference in New Issue
Block a user