Remove destroy with js format in variants controller, we dont use this endpoint in OFN and it avoids having to bring additional code from spree_backend

This commit is contained in:
luisramos0
2019-12-17 11:40:48 +00:00
parent 70a24b25e2
commit 1e203ae419
2 changed files with 1 additions and 32 deletions

View File

@@ -35,7 +35,6 @@ module Spree
respond_with(@variant) do |format|
format.html { redirect_to admin_product_variants_url(params[:product_id]) }
format.js { render_js_for_destroy }
end
end

View File

@@ -39,36 +39,6 @@ module Spree
describe '#destroy' do
let(:variant) { create(:variant) }
context 'when requesting with js' do
before do
allow(Spree::Variant).to receive(:find).with(variant.id.to_s) { variant }
allow(variant).to receive(:destroy).and_call_original
end
it 'destroys the variant' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
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 be
end
it 'renders spree/admin/shared/destroy' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
expect(response).to render_template('spree/admin/shared/_destroy')
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
before do
allow(Spree::Variant).to receive(:find).with(variant.id.to_s) { variant }
@@ -98,7 +68,7 @@ module Spree
exchange = create(:exchange)
variant.exchanges << exchange
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'js'
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink, format: 'html'
expect(variant.exchanges).to be_empty
end
end