Skip to content

Commit cf6734f

Browse files
rizwanrezawycats
authored andcommitted
Add more tests and docs to uncountable routes. [#3930 state:resolved]
1 parent 72074aa commit cf6734f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

actionpack/lib/action_dispatch/routing/mapper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,11 @@ def member_name
425425
singular
426426
end
427427

428+
# Checks for uncountable plurals, and appends "_index" if they're.
428429
def collection_name
429430
uncountable? ? "#{plural}_index" : plural
430431
end
431-
432+
432433
def uncountable?
433434
singular == plural
434435
end

actionpack/test/dispatch/routing_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def self.matches?(request)
113113
resources :posts, :only => [:index, :show] do
114114
resources :comments, :except => :destroy
115115
end
116-
116+
117117
resources :sheep
118118

119119
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
@@ -532,11 +532,13 @@ def test_resource_routes_with_only_and_except
532532
assert_raise(ActionController::RoutingError) { delete '/posts/1/comments' }
533533
end
534534
end
535-
535+
536536
def test_resources_for_uncountable_names
537537
with_test_routes do
538538
assert_equal '/sheep', sheep_index_path
539539
assert_equal '/sheep/1', sheep_path(1)
540+
assert_equal '/sheep/new', new_sheep_path
541+
assert_equal '/sheep/1/edit', edit_sheep_path(1)
540542
end
541543
end
542544

0 commit comments

Comments
 (0)