From 4d4d2179f68ecda5736feb6cccd897b73653bce9 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Thu, 28 Jul 2011 20:00:48 +0200 Subject: 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. --- actionpack/lib/action_dispatch/routing/mapper.rb | 12 ++++++------ actionpack/test/controller/resources_test.rb | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 8d071b2061..36d878aee9 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -879,9 +879,9 @@ module ActionDispatch 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 @@ -945,9 +945,9 @@ module ActionDispatch 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 diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 6ea492cf8b..3b1b5fc3ec 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -91,6 +91,15 @@ class ResourcesTest < ActionController::TestCase 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') -- cgit v1.2.3