8000 Fix error when routing with array containing symbol. · activeadmin/activeadmin@701880e · GitHub
[go: up one dir, main page]

Skip to content

Commit 701880e

Browse files
author
Jake Wesorick
committed
Fix error when routing with array containing symbol.
1 parent 5a7db30 commit 701880e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/active_admin/resource_controller/polymorphic_routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def to_named_resource(record)
2525
return ActiveAdmin::Model.new(active_admin_config, record)
2626
end
2727

28-
if record.is_a?(parent.class)
28+
if respond_to?(:parent, true) && record.is_a?(parent.class)
2929
return ActiveAdmin::Model.new(active_admin_config.belongs_to_config.resource, record)
3030
end
3131

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe ActiveAdmin::ResourceController::PolymorphicRoutes, type: :controller do
4+
let(:klass) { Admin::PostsController }
5+
6+
shared_context 'with post config' do
7+
before do
8+
load_resources { post_config }
9+
10+
@controller = klass.new
11+
12+
get :index
13+
end
14+
end
15+
16+
context 'polymorphic routes' do
17+
include_context 'with post config' do
18+
let(:post_config) { ActiveAdmin.register Post }
19+
let(:post) { Post.create! title: "Hello World" }
20+
end
21+
22+
%w(polymorphic_url polymorphic_path).each do |method|
23+
describe method do
24+
it 'arrays wtih action names' do
25+
expect(controller.send(method, [:admin, post])).to include("/admin/posts/#{post.id}")
26+
end
27+
end
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)
0