Add enterprise cache invalidation for order cycle changes

This commit is contained in:
Rohan Mitchell
2016-10-28 16:33:27 +11:00
parent bd11c6ce14
commit 1ea4f4274c
2 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -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