Permalink
Browse files

Fix singleton resource named routes

  • Loading branch information...
1 parent 2ee130a commit b2578a148cb78b4f238ad92864c9d9e509e5e451 @josh josh committed Jan 15, 2010
Showing with 5 additions and 2 deletions.
  1. +2 −2 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +3 −0 actionpack/test/dispatch/routing_test.rb
@@ -448,8 +448,8 @@ def resource(*resources, &block)
post :create if resource.actions.include?(:create)
put :update if resource.actions.include?(:update)
delete :destroy if resource.actions.include?(:destroy)
- get :new, :as => "new_#{resource.singular}" if resource.actions.include?(:new)
- get :edit, :as => "edit_#{resource.singular}" if resource.actions.include?(:edit)
+ get :new, :as => resource.singular if resource.actions.include?(:new)
+ get :edit, :as => resource.singular if resource.actions.include?(:edit)
end
end
@@ -207,6 +207,7 @@ def test_session_singleton_resource
with_test_routes do
get '/session'
assert_equal 'sessions#create', @response.body
+ assert_equal '/session', session_path
post '/session'
assert_equal 'sessions#create', @response.body
@@ -219,9 +220,11 @@ def test_session_singleton_resource
get '/session/new'
assert_equal 'sessions#new', @response.body
+ assert_equal '/session/new', new_session_path
get '/session/edit'
assert_equal 'sessions#edit', @response.body
+ assert_equal '/session/edit', edit_session_path
end
end

0 comments on commit b2578a1

Please sign in to comment.