mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Test that we refresh the cache on variant destroy
These tests prove that https://github.com/openfoodfoundation/openfoodnetwork/issues/3629 is indeed is a bug because we don't refresh the cache when deleting a variant.
This commit is contained in:
@@ -59,6 +59,19 @@ module Spree
|
||||
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
|
||||
expect(response).to render_template('spree/admin/shared/_destroy')
|
||||
end
|
||||
|
||||
it 'refreshes the cache' do
|
||||
expect(OpenFoodNetwork::ProductsCache).to receive(:variant_destroyed).with(variant)
|
||||
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
|
||||
end
|
||||
|
||||
it 'destroys all its exchanges' do
|
||||
exchange = create(:exchange)
|
||||
variant.exchanges << exchange
|
||||
|
||||
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
|
||||
expect(variant.exchanges).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'when requesting with html' do
|
||||
@@ -85,6 +98,19 @@ module Spree
|
||||
product_id: variant.product.permalink
|
||||
)
|
||||
end
|
||||
|
||||
it 'refreshes the cache' do
|
||||
expect(OpenFoodNetwork::ProductsCache).to receive(:variant_destroyed).with(variant)
|
||||
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
|
||||
end
|
||||
|
||||
it 'destroys all its exchanges' do
|
||||
exchange = create(:exchange)
|
||||
variant.exchanges << exchange
|
||||
|
||||
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
|
||||
expect(variant.exchanges).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user