From c9417dcef379ec3e87fed63d32636697c2d19939 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 1 Aug 2006 01:23:06 +0000 Subject: Nested resource testing. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4643 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/resources_test.rb | 33 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index e2ef2a819d..845f8878f2 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -1,14 +1,14 @@ require File.dirname(__FILE__) + '/../abstract_unit' -class MessagesController < ActionController::Base +class ResourcesController < ActionController::Base def index() render :nothing => true end def rescue_action(e) raise e end end -class CommentsController < ActionController::Base - def index() render :nothing => true end - def rescue_action(e) raise e end -end +class ThreadsController < ResourcesController; end +class MessagesController < ResourcesController; end +class CommentsController < ResourcesController; end + class ResourcesTest < Test::Unit::TestCase def test_should_arrange_actions @@ -116,20 +116,21 @@ class ResourcesTest < Test::Unit::TestCase def test_nested_restful_routes with_routing do |set| - set.draw do |map| - map.resources(:messages) do |map| - map.resources(:comments) + set.draw do |map| + map.resources :threads do |map| + map.resources :messages do |map| + map.resources :comments + end end end - with_options(:controller => 'comments', :message_id => '1') do |controller| - controller.assert_routing "/messages/1/comments", :action => 'index' - controller.assert_routing "/messages/1/comments.xml" , :action => 'index', :format => 'xml' - controller.assert_routing "/messages/1/comments/new", :action => 'new' - controller.assert_routing "/messages/1/comments/1", :action => 'show', :id => '1' - controller.assert_routing "/messages/1/comments/1;edit", :action => 'edit', :id => '1' - controller.assert_routing "/messages/1/comments/1.xml", :action => 'show', :id => '1', :format => 'xml' - end + assert_simply_restful_for :threads + assert_simply_restful_for :messages, + :path_prefix => 'threads/1/', + :options => { :thread_id => '1' } + assert_simply_restful_for :comments, + :path_prefix => 'threads/1/messages/2/', + :options => { :thread_id => '1', :message_id => '2' } end end -- cgit v1.2.3