Skip to content

Commit

Permalink
Add more tests and docs to uncountable routes. [#3930 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
rizwanreza authored and wycats committed Mar 29, 2010
1 parent 72074aa commit cf6734f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -425,10 +425,11 @@ def member_name
singular
end

# Checks for uncountable plurals, and appends "_index" if they're.
def collection_name
uncountable? ? "#{plural}_index" : plural
end

def uncountable?
singular == plural
end
Expand Down
6 changes: 4 additions & 2 deletions actionpack/test/dispatch/routing_test.rb
Expand Up @@ -113,7 +113,7 @@ def self.matches?(request)
resources :posts, :only => [:index, :show] do
resources :comments, :except => :destroy
end

resources :sheep

match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
Expand Down Expand Up @@ -532,11 +532,13 @@ def test_resource_routes_with_only_and_except
assert_raise(ActionController::RoutingError) { delete '/posts/1/comments' }
end
end

def test_resources_for_uncountable_names
with_test_routes do
assert_equal '/sheep', sheep_index_path
assert_equal '/sheep/1', sheep_path(1)
assert_equal '/sheep/new', new_sheep_path
assert_equal '/sheep/1/edit', edit_sheep_path(1)
end
end

Expand Down

0 comments on commit cf6734f

Please sign in to comment.