Permalink
Browse files

Merge pull request #2332 from thedarkone/resources-router-fix-3-1

Backport #2330 into 3-1-stable
  • Loading branch information...
2 parents b4cf291 + 34c5089 commit 7f5dc9887b426f4f20145b181265abbde1fe6c2f @josevalim josevalim committed Jul 28, 2011
Showing with 16 additions and 8 deletions.
  1. +7 −8 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +9 −0 actionpack/test/controller/resources_test.rb
View
15 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -877,9 +877,9 @@ class Resource #:nodoc:
def initialize(entities, options = {})
@name = entities.to_s
- @path = (options.delete(:path) || @name).to_s
- @controller = (options.delete(:controller) || @name).to_s
- @as = options.delete(:as)
+ @path = (options[:path] || @name).to_s
+ @controller = (options[:controller] || @name).to_s
+ @as = options[:as]
@options = options
end
@@ -941,12 +941,11 @@ class SingletonResource < Resource #:nodoc:
DEFAULT_ACTIONS = [:show, :create, :update, :destroy, :new, :edit]
def initialize(entities, options)
+ super
+
@as = nil
- @name = entities.to_s
- @path = (options.delete(:path) || @name).to_s
- @controller = (options.delete(:controller) || plural).to_s
- @as = options.delete(:as)
- @options = options
+ @controller = (options[:controller] || plural).to_s
+ @as = options[:as]
end
def plural
View
9 actionpack/test/controller/resources_test.rb
@@ -91,6 +91,15 @@ def test_multiple_default_restful_routes
end
end
+ def test_multiple_resources_with_options
+ expected_options = {:controller => 'threads', :action => 'index'}
+
+ with_restful_routing :messages, :comments, expected_options.slice(:controller) do
+ assert_recognizes(expected_options, :path => 'comments')
+ assert_recognizes(expected_options, :path => 'messages')
+ end
+ end
+
def test_with_custom_conditions
with_restful_routing :messages, :conditions => { :subdomain => 'app' } do
assert @routes.recognize_path("/messages", :method => :get, :subdomain => 'app')

0 comments on commit 7f5dc98

Please sign in to comment.