Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix typo - (parent) in location_after_destroy. (#11256)
Matthew Kennedy1178d901fd11
diff --git a/backend/app/controllers/spree/admin/images_controller.rb b/backend/app/controllers/spree/admin/images_controller.rbindex cc43b7d382..d765abb033 100644--- a/backend/app/controllers/spree/admin/images_controller.rb+++ b/backend/app/controllers/spree/admin/images_controller.rb@@ -13,7 +13,7 @@ module Spreeprivatedef location_after_destroy- spree.admin_product_images_url(@arent)+ spree.admin_product_images_url(parent)enddef location_after_savediff --git a/backend/spec/controllers/spree/admin/images_controller_spec.rb b/backend/spec/controllers/spree/admin/images_controller_spec.rbindex 9ac760f3ae..8e77da7027 100644--- a/backend/spec/controllers/spree/admin/images_controller_spec.rb+++ b/backend/spec/controllers/spree/admin/images_controller_spec.rb@@ -22,42 +22,83 @@ module Spreeenddescribe '#destroy' do- subject(:send_request) do- delete :destroy, params: { product_id: product, id: image, format: :js }- end+ context 'when request format is javascript' do+ subject(:send_request) do+ delete :destroy, params: { product_id: product, id: image, format: :js }+ end- let(:image) { create(:image, viewable: product.master) }+ let(:image) { create(:image, viewable: product.master) }- shared_examples 'correct response' do- it { expect(assigns(:image)).to eq(image) }- it { expect(response).to have_http_status(:ok) }- end+ shared_examples 'correct response' do+ it { expect(assigns(:image)).to eq(image) }+ it { expect(response).to have_http_status(:ok) }+ end- context 'will successfully destroy image' do- describe 'returns response' do- before { send_request }+ context 'will successfully destroy image' do+ describe 'returns response' do+ before { send_request }- it_behaves_like 'correct response'- it { expect(flash[:success]).to eq('Image has been successfully removed!') }+ it_behaves_like 'correct response'+ it { expect(flash[:success]).to eq('Image has been successfully removed!') }+ endend- end- context 'cannot destroy image of other product' do- let(:other_product) { create(:product, stores: [store]) }- let(:image) { create(:image, viewable: other_product) }+ context 'cannot destroy image of other product' do+ let(:other_product) { create(:product, stores: [store]) }+ let(:image) { create(:image, viewable: other_product) }- it { expect(send_request).to redirect_to(spree.admin_product_images_path(product)) }+ it { expect(send_request).to redirect_to(spree.admin_product_images_path(product)) }- it do- send_request- expect(flash[:error]).to eq('Image is not found')+ it do+ send_request+ expect(flash[:error]).to eq('Image is not found')+ end+ end++ context 'cannot destroy image of product from different store' do+ let(:product) { create(:product, stores: [create(:store)]) }++ it { expect { send_request }.to raise_error(ActiveRecord::RecordNotFound) }endend- context 'cannot destroy image of product from different store' do- let(:product) { create(:product, stores: [create(:store)]) }+ context 'when request format is html' do+ subject(:send_request) do+ delete :destroy, params: { product_id: product, id: image, format: :html }+ end- it { expect { send_request }.to raise_error(ActiveRecord::RecordNotFound) }+ let(:image) { create(:image, viewable: product.master) }++ shared_examples 'correct response' do+ it { expect(assigns(:image)).to eq(image) }+ it { expect(response).to have_http_status(:ok) }+ end++ context 'will successfully destroy image' do+ describe 'returns response' do+ before { send_request }++ it { expect(send_request).to redirect_to(spree.admin_product_images_path(product)) }+ end+ end++ context 'cannot destroy image of other product' do+ let(:other_product) { create(:product, stores: [store]) }+ let(:image) { create(:image, viewable: other_product) }++ it { expect(send_request).to redirect_to(spree.admin_product_images_path(product)) }++ it do+ send_request+ expect(flash[:error]).to eq('Image is not found')+ end+ end++ context 'cannot destroy image of product from different store' do+ let(:product) { create(:product, stores: [create(:store)]) }++ it { expect { send_request }.to raise_error(ActiveRecord::RecordNotFound) }+ endendendend