aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-04-26 23:11:31 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-04-26 23:11:31 +0000
commit63aea3ffa9897e748ff03dd119605453d518ac3f (patch)
tree6620cb06b8d988f87c5b6a8b16147cc722a09f5c /actionpack/test/controller
parent234b0b7ca021cff6e36376c38b7c70321b8550f1 (diff)
downloadrails-63aea3ffa9897e748ff03dd119605453d518ac3f.tar.gz
rails-63aea3ffa9897e748ff03dd119605453d518ac3f.tar.bz2
rails-63aea3ffa9897e748ff03dd119605453d518ac3f.zip
Added :has_many and :has_one for declaring plural and singular resources beneath the current [DHH] Added :name_prefix as standard for nested resources [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6588 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/resources_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 3d85f49c4c..278e4b1512 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -9,6 +9,8 @@ end
class ThreadsController < ResourcesController; end
class MessagesController < ResourcesController; end
class CommentsController < ResourcesController; end
+class AuthorsController < ResourcesController; end
+class LogoController < ResourcesController; end
class AccountController < ResourcesController; end
class AdminController < ResourcesController; end
@@ -247,6 +249,29 @@ class ResourcesTest < Test::Unit::TestCase
assert_singleton_restful_for :account, :path_prefix => 'admin/'
end
end
+
+ def test_resource_has_many_should_become_nested_resources
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :messages, :has_many => [ :comments, :authors ]
+ end
+
+ assert_simply_restful_for :messages
+ assert_simply_restful_for :comments, :path_prefix => 'messages/1/', :options => { :message_id => '1' }
+ assert_simply_restful_for :authors, :path_prefix => 'messages/1/', :options => { :message_id => '1' }
+ end
+ end
+
+ def test_resource_has_one_should_become_nested_resources
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :messages, :has_one => :logo
+ end
+
+ assert_simply_restful_for :messages
+ assert_singleton_restful_for :logo, :path_prefix => 'messages/1/', :options => { :message_id => '1' }
+ end
+ end
def test_singleton_resource_with_member_action
[:put, :post].each do |method|