From 63aea3ffa9897e748ff03dd119605453d518ac3f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 26 Apr 2007 23:11:31 +0000 Subject: 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 --- actionpack/test/controller/resources_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'actionpack/test/controller') 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| -- cgit v1.2.3