Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Fixed: admin taxon show page should redirect to edit screen (#12515)

Damian Legawiec8661d9c72cff
diff --git a/admin/app/controllers/spree/admin/taxons_controller.rb b/admin/app/controllers/spree/admin/taxons_controller.rb
index 3510f3c302..5c4418499c 100644
--- a/admin/app/controllers/spree/admin/taxons_controller.rb
+++ b/admin/app/controllers/spree/admin/taxons_controller.rb
@@ -13,7 +13,11 @@ module Spree
update.before :set_parent
update.before :set_position
- before_action :load_form_data, only: [:show, :new, :create, :edit, :update]
+ before_action :load_form_data, only: [:new, :create, :edit, :update]
+
+ def show
+ redirect_to location_after_save
+ end
def select_options
render json: taxons_options_json_array(with_automatic: params[:with_automatic].to_b)
diff --git a/admin/spec/controllers/spree/admin/taxons_controller_spec.rb b/admin/spec/controllers/spree/admin/taxons_controller_spec.rb
index 2bf8f3b9ca..abea957ff9 100644
--- a/admin/spec/controllers/spree/admin/taxons_controller_spec.rb
+++ b/admin/spec/controllers/spree/admin/taxons_controller_spec.rb
@@ -22,6 +22,33 @@ RSpec.describe Spree::Admin::TaxonsController, type: :controller do
end
end
+ describe 'GET #show' do
+ let(:taxon) { create(:taxon, taxonomy: taxonomy) }
+
+ it 'redirects to the edit page' do
+ get :show, params: { taxonomy_id: taxonomy.id, id: taxon.id }
+ expect(response).to redirect_to(spree.edit_admin_taxonomy_taxon_path(taxonomy.id, taxon.id))
+ end
+ end
+
+ describe 'GET #edit' do
+ let(:taxon) { create(:taxon, taxonomy: taxonomy) }
+
+ it 'returns a successful response' do
+ get :edit, params: { taxonomy_id: taxonomy.id, id: taxon.id }
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'PUT #update' do
+ let(:taxon) { create(:taxon, taxonomy: taxonomy) }
+
+ it 'returns a successful response' do
+ put :update, params: { taxonomy_id: taxonomy.id, id: taxon.id, taxon: { name: 'New Name' } }
+ expect(response).to redirect_to(spree.edit_admin_taxonomy_taxon_path(taxonomy.id, taxon.id))
+ end
+ end
+
describe 'PUT #reposition' do
let(:taxon) { create(:taxon, taxonomy: taxonomy) }
let(:new_parent) { create(:taxon, taxonomy: taxonomy) }