aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/resources_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/resources_test.rb')
-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|