diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-07-31 20:32:48 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-07-31 20:32:48 +0000 |
commit | d2eafa8b736c2f300658925e70290fb3d996959b (patch) | |
tree | f9731c6cfea3caba236a2ae7fcebeb2e58b9d49b /actionpack | |
parent | ed4c295c4782b534121b04a6bc10b9f440ffa8c6 (diff) | |
download | rails-d2eafa8b736c2f300658925e70290fb3d996959b.tar.gz rails-d2eafa8b736c2f300658925e70290fb3d996959b.tar.bz2 rails-d2eafa8b736c2f300658925e70290fb3d996959b.zip |
Dup the options passed to map.resources so that multiple resources get the same options. [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4639 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/resources.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 19 |
3 files changed, 20 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index f45051314f..c5d8154ed2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Dup the options passed to map.resources so that multiple resources get the same options. [Rick Olson] + * Fixed the new_#{resource}_url route and added named route tests for Simply Restful. [Rick Olson] * Added map.resources from the Simply Restful plugin [DHH]. Examples (the API has changed to use plurals!): diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index b41cdf16e9..93016cbcc5 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -84,7 +84,7 @@ module ActionController def resources(*entities) options = entities.last.is_a?(Hash) ? entities.pop : { } - entities.each { |entity| map_resource(entity, options) { yield if block_given? } } + entities.each { |entity| map_resource(entity, options.dup) { yield if block_given? } } end private diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 054c251d59..bc8fc76536 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -6,6 +6,7 @@ class MessagesController < ActionController::Base end class CommentsController < ActionController::Base + def index() render :nothing => true end def rescue_action(e) raise e end end @@ -16,12 +17,26 @@ class ResourcesTest < Test::Unit::TestCase end end + def test_multiple_default_restful_routes + with_restful_routing :messages, :comments do + assert_simply_restful_for :messages + assert_simply_restful_for :comments + end + end + def test_with_path_prefix with_restful_routing :messages, :path_prefix => '/thread/:thread_id' do assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } end end + def test_multile_with_path_prefix + with_restful_routing :messages, :comments, :path_prefix => '/thread/:thread_id' do + assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } + assert_simply_restful_for :comments, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } + end + end + def test_with_collection_action with_restful_routing :messages, :collection => { :rss => :get } do rss_options = {:action => 'rss'} @@ -86,9 +101,9 @@ class ResourcesTest < Test::Unit::TestCase end protected - def with_restful_routing(resource, *args) + def with_restful_routing(*args) with_routing do |set| - set.draw { |map| map.resources(resource, *args) } + set.draw { |map| map.resources(*args) } yield end end |