mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Refresh cache when option type destroyed
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user