Skip to content

Commit

Permalink
Dynamically generaeted helpers on collection should not clobber resou…
Browse files Browse the repository at this point in the history
…rces url helper [#6028 state:resolved]
  • Loading branch information
josevalim committed Nov 25, 2010
1 parent 08e9d0d commit 7e903a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -1265,6 +1265,8 @@ def name_for_action(as, action)
name_prefix = @scope[:as] name_prefix = @scope[:as]


if parent_resource if parent_resource
return nil if as.nil? && action.nil?

collection_name = parent_resource.collection_name collection_name = parent_resource.collection_name
member_name = parent_resource.member_name member_name = parent_resource.member_name
end end
Expand Down
11 changes: 11 additions & 0 deletions actionpack/test/dispatch/routing_test.rb
Expand Up @@ -155,6 +155,11 @@ def self.matches?(request)
end end


resources :replies do resources :replies do
collection do
get 'page/:page' => 'replies#index', :page => %r{\d+}
get ':page' => 'replies#index', :page => %r{\d+}
end

new do new do
post :preview post :preview
end end
Expand Down Expand Up @@ -1249,6 +1254,12 @@ def test_match_shorthand_inside_namespace
end end
end end


def test_dynamically_generated_helpers_on_collection_do_not_clobber_resources_url_helper
with_test_routes do
assert_equal '/replies', replies_path
end
end

def test_scoped_controller_with_namespace_and_action def test_scoped_controller_with_namespace_and_action
with_test_routes do with_test_routes do
assert_equal '/account/twitter/callback', account_callback_path("twitter") assert_equal '/account/twitter/callback', account_callback_path("twitter")
Expand Down

0 comments on commit 7e903a3

Please sign in to comment.