Refresh cache when option type destroyed

This commit is contained in:
Rohan Mitchell
2016-02-26 10:09:16 +11:00
parent 8928e461d4
commit 45a7b13e9a

View File

@@ -4,9 +4,14 @@ module Spree
describe OptionType do
describe "products cache" do
let!(:product) { create(:simple_product, option_types: [option_type]) }
let(:variant) { product.variants.first }
let(:option_type) { create(:option_type) }
let(:option_value) { create(:option_value, option_type: option_type) }
before { option_type.reload }
before do
option_type.reload
variant.option_values << option_value
end
it "refreshes the products cache on change, via product" do
expect(OpenFoodNetwork::ProductsCache).to receive(:product_changed).with(product)
@@ -14,7 +19,10 @@ module Spree
option_type.save!
end
# When a OptionType is destroyed, the destruction of the OptionValues refreshes the cache
it "refreshes the products cache on destruction, via option value destruction" do
expect(OpenFoodNetwork::ProductsCache).to receive(:variant_changed).with(variant)
option_type.destroy
end
end
end
end