From 0b1849da4151b21f083ca7c28915de96284bcd46 Mon Sep 17 00:00:00 2001 From: Josh Frankel Date: Thu, 2 Apr 2026 15:59:46 -0400 Subject: [PATCH] Ensure route collisions don't occur with `admin/controller/batch_action` and `admin/controller/:id` (#show) --- config/routes.rb | 2 +- spec/routes_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index fea1706..8c413f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,7 +19,7 @@ def controllers_for(path) prefixless_controller_path = controller_path.delete_prefix('admin/') scope path: :admin, as: :admin do - post "#{prefixless_controller_path}/#{method_name}", + post "administrate_batch_actions/#{prefixless_controller_path}/#{method_name}", to: "#{controller_path}##{method_name}", as: "#{method_name}_#{prefixless_controller_path}" end diff --git a/spec/routes_spec.rb b/spec/routes_spec.rb index 04f44b9..2103f83 100644 --- a/spec/routes_spec.rb +++ b/spec/routes_spec.rb @@ -2,7 +2,7 @@ RSpec.describe 'Routes', type: :routing do it 'has route to the batch action' do - expect(admin_dummy_batch_action_dummy_path).to eq('/admin/dummy/dummy_batch_action') + expect(admin_dummy_batch_action_dummy_path).to eq('/admin/administrate_batch_actions/dummy/dummy_batch_action') expect(post: admin_dummy_batch_action_dummy_path).to route_to( controller: 'admin/dummy', action: 'dummy_batch_action' @@ -10,7 +10,7 @@ end it 'has route to the batch action in a nested namespace' do - expect(admin_my_batch_action_nested_namespace_path).to eq('/admin/nested/namespace/my_batch_action') + expect(admin_my_batch_action_nested_namespace_path).to eq('/admin/administrate_batch_actions/nested/namespace/my_batch_action') expect(post: admin_my_batch_action_nested_namespace_path).to route_to( controller: 'admin/nested/namespace', action: 'my_batch_action'