Skip to content
This repository
Browse code

Nested resource testing.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4643 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c9417dcef379ec3e87fed63d32636697c2d19939 1 parent a247d72
Jeremy Kemper authored August 01, 2006
2  actionpack/lib/action_controller/resources.rb
@@ -34,7 +34,7 @@ def member_path
34 34
       end
35 35
       
36 36
       def nesting_path_prefix
37  
-        "#{path_prefix}/#{plural}/:#{singular}_id"
  37
+        "#{path}/:#{singular}_id"
38 38
       end
39 39
       
40 40
       private
33  actionpack/test/controller/resources_test.rb
... ...
@@ -1,14 +1,14 @@
1 1
 require File.dirname(__FILE__) + '/../abstract_unit'
2 2
 
3  
-class MessagesController < ActionController::Base
  3
+class ResourcesController < ActionController::Base
4 4
   def index() render :nothing => true end
5 5
   def rescue_action(e) raise e end
6 6
 end
7 7
 
8  
-class CommentsController < ActionController::Base
9  
-  def index() render :nothing => true end
10  
-  def rescue_action(e) raise e end
11  
-end
  8
+class ThreadsController  < ResourcesController; end
  9
+class MessagesController < ResourcesController; end
  10
+class CommentsController < ResourcesController; end
  11
+
12 12
 
13 13
 class ResourcesTest < Test::Unit::TestCase
14 14
   def test_should_arrange_actions
@@ -116,20 +116,21 @@ def test_with_new_action
116 116
 
117 117
   def test_nested_restful_routes
118 118
     with_routing do |set|
119  
-      set.draw do |map| 
120  
-        map.resources(:messages) do |map|
121  
-          map.resources(:comments)
  119
+      set.draw do |map|
  120
+        map.resources :threads do |map|
  121
+          map.resources :messages do |map|
  122
+            map.resources :comments
  123
+          end
122 124
         end
123 125
       end
124 126
 
125  
-      with_options(:controller => 'comments', :message_id => '1') do |controller|
126  
-        controller.assert_routing "/messages/1/comments",        :action => 'index'
127  
-        controller.assert_routing "/messages/1/comments.xml" ,   :action => 'index', :format => 'xml'
128  
-        controller.assert_routing "/messages/1/comments/new",    :action => 'new'
129  
-        controller.assert_routing "/messages/1/comments/1",      :action => 'show', :id => '1'
130  
-        controller.assert_routing "/messages/1/comments/1;edit", :action => 'edit', :id => '1'
131  
-        controller.assert_routing "/messages/1/comments/1.xml",  :action => 'show', :id => '1', :format => 'xml'
132  
-      end
  127
+      assert_simply_restful_for :threads
  128
+      assert_simply_restful_for :messages,
  129
+        :path_prefix => 'threads/1/',
  130
+        :options => { :thread_id => '1' }
  131
+      assert_simply_restful_for :comments,
  132
+        :path_prefix => 'threads/1/messages/2/',
  133
+        :options => { :thread_id => '1', :message_id => '2' }
133 134
     end
134 135
   end
135 136
 

0 notes on commit c9417dc

Please sign in to comment.
Something went wrong with that request. Please try again.