8000 Fix error when routing with array containing symbol. by JWesorick · Pull Request #5870 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content

Fix error when routing with array containing symbol. #5870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug Fixes

* Use filter label when condition has a predicate. [#5886] by [@ko-lem]
* Fix error when routing with array containing symbol. [#5870] by [@jwesorick]

### Removals

Expand Down Expand Up @@ -526,6 +527,7 @@ Please check [0-6-stable] for previous changes.
[#5874]: https://github.com/activeadmin/activeadmin/pull/5874
[#5877]: https://github.com/activeadmin/activeadmin/pull/5877
[#5886]: https://github.com/activeadmin/activeadmin/pull/5886
[#5870]: https://github.com/activeadmin/activeadmin/pull/5870

[@5t111111]: https://github.com/5t111111
[@aarek]: https://github.com/aarek
Expand Down Expand Up @@ -566,6 +568,7 @@ Please check [0-6-stable] for previous changes.
[@johnnyshields]: https://github.com/johnnyshields
[@jscheid]: https://github.com/jscheid
[@juril33t]: https://github.com/juril33t
[@jwesorick]: https://github.com/jwesorick
[@kjeldahl]: https://github.com/kjeldahl
[@ko-lem]: https://github.com/ko-lem
[@kobeumut]: https://github.com/kobeumut
Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/resource_controller/polymorphic_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def to_named_resource(record)
return ActiveAdmin::Model.new(active_admin_config, record)
end

if record.is_a?(parent.class)
if respond_to?(:parent, true) && record.is_a?(parent.class)
return ActiveAdmin::Model.new(active_admin_config.belongs_to_config.resource, record)
end

Expand Down
30 changes: 30 additions & 0 deletions spec/unit/resource_controller/polymorphic_routes_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'rails_helper'

RSpec.describe ActiveAdmin::ResourceController::PolymorphicRoutes, type: :controller do
let(:klass) { Admin::PostsController }

shared_context 'with post config' do
before do
load_resources { post_config }

@controller = klass.new

get :index
end
end

context 'polymorphic routes' do
include_context 'with post config' do
let(:post_config) { ActiveAdmin.register Post }
let(:post) { Post.create! title: "Hello World" }
end

%w(polymorphic_url polymorphic_path).each do |method|
describe method do
it 'arrays wtih action names' do
expect(controller.send(method, [:admin, post])).to include("/admin/posts/#{post.id}")
end
end
end
end
end
0