Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

There is no need to be destructive with the passed-in options.

This fixes a bug that is caused by Resource/SingletonResource mangling resource options when using inline "multi"-resource declarations.
  • Loading branch information...
commit 0753d0bd0566c11b43faa62fcf4322a04cb5abdc 1 parent b4cf291
thedarkone thedarkone authored
12 actionpack/lib/action_dispatch/routing/mapper.rb
View
@@ -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
@@ -943,9 +943,9 @@ class SingletonResource < Resource #:nodoc:
def initialize(entities, options)
@as = nil
@name = entities.to_s
- @path = (options.delete(:path) || @name).to_s
- @controller = (options.delete(:controller) || plural).to_s
- @as = options.delete(:as)
+ @path = (options[:path] || @name).to_s
+ @controller = (options[:controller] || plural).to_s
+ @as = options[:as]
@options = options
end
9 actionpack/test/controller/resources_test.rb
View
@@ -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')
Please sign in to comment.
Something went wrong with that request. Please try again.