diff --git a/spec/models/spree/option_type_spec.rb b/spec/models/spree/option_type_spec.rb index e93f35ec49..cfc0654733 100644 --- a/spec/models/spree/option_type_spec.rb +++ b/spec/models/spree/option_type_spec.rb @@ -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