Make VariantController specs aware of destroy call

In v2 we no longer rely on `Variant#delete` but `Variant#destroy` so
stubbed calls needed fixing.
This commit is contained in:
Pau Perez
2019-04-05 15:38:10 +02:00
parent d866fad46e
commit 3e7e24d700

View File

@@ -42,17 +42,17 @@ module Spree
context 'when requesting with js' do
before do
allow(Spree::Variant).to receive(:find).with(variant.id.to_s) { variant }
allow(variant).to receive(:delete)
allow(variant).to receive(:destroy).and_call_original
end
it 'deletes the variant' do
it 'destroys the variant' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
expect(variant).to have_received(:delete)
expect(variant).to have_received(:destroy)
end
it 'shows a success flash message' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
expect(flash[:success]).to eq(I18n.t('notice_messages.variant_deleted'))
expect(flash[:success]).to be
end
it 'renders spree/admin/shared/destroy' do
@@ -77,17 +77,17 @@ module Spree
context 'when requesting with html' do
before do
allow(Spree::Variant).to receive(:find).with(variant.id.to_s) { variant }
allow(variant).to receive(:delete)
allow(variant).to receive(:destroy).and_call_original
end
it 'deletes the variant' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'html'
expect(variant).to have_received(:delete)
expect(variant).to have_received(:destroy)
end
it 'shows a success flash message' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'html'
expect(flash[:success]).to eq(I18n.t('notice_messages.variant_deleted'))
expect(flash[:success]).to be
end
it 'redirects to admin_product_variants_url' do