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

Skip to content

Commit 9e7e5e8

Browse files
author
Jake Wesorick
committed
Fix error when routing with array containing symbol.
1 parent 241dd5c commit 9e7e5e8

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
## Unreleased
44

5-
## 2.4.0 [](https://github.com/activeadmin/activeadmin/compare/v2.3.1..v2.4.0)
5+
* Fix error when routing with array containing symbol. [#5870] by [@jwesorick]
66

77
### Enhancements
88

99
* Make optimization to not use expensive COUNT queries also work for decorated actions. [#5811] by [@irmela]
1010
* Render a text filter instead of a select for large associations (opt-in) [#5548] by [@DanielHeath]
11-
* Improve German translations [#5874] by [@juril33t]
1211

1312
## 2.3.1 [](https://github.com/activeadmin/activeadmin/compare/v2.3.0..v2.3.1)
1413

@@ -515,7 +514,7 @@ Please check [0-6-stable] for previous changes.
515514
[#5548]: https://github.com/activeadmin/activeadmin/pull/5548
516515
[#5842]: https://github.com/activeadmin/activeadmin/pull/5842
517516
[#5854]: https://github.com/activeadmin/activeadmin/pull/5854
518-
[#5874]: https://github.com/activeadmin/activeadmin/pull/< 10000 span class="x x-first x-last">5874
517+
[#5870]: https://github.com/activeadmin/activeadmin/pull/5870
519518

520519
[@5t111111]: https://github.com/5t111111
521520
[@aarek]: https://github.com/aarek
@@ -555,7 +554,7 @@ Please check [0-6-stable] for previous changes.
555554
[@JiiHu]: https://github.com/JiiHu
556555
[@johnnyshields]: https://github.com/johnnyshields
557556
[@jscheid]: https://github.com/jscheid
558-
[@juril33t]: https://github.com/juril33t
557+
[@jwesorick]: https://github.com/jwesorick
559558
[@kjeldahl]: https://github.com/kjeldahl
560559
[@kobeumut]: https://github.com/kobeumut
561560
[@Kris-LIBIS]: https://github.com/Kris-LIBIS

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