aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-08-01 01:23:06 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-08-01 01:23:06 +0000
commitc9417dcef379ec3e87fed63d32636697c2d19939 (patch)
tree16d593ce52583a47f9d0741b41a03dea082a1f89 /actionpack
parenta247d72139f918e38c129d31572167db5170ee5d (diff)
downloadrails-c9417dcef379ec3e87fed63d32636697c2d19939.tar.gz
rails-c9417dcef379ec3e87fed63d32636697c2d19939.tar.bz2
rails-c9417dcef379ec3e87fed63d32636697c2d19939.zip
Nested resource testing.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4643 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/resources.rb2
-rw-r--r--actionpack/test/controller/resources_test.rb33
2 files changed, 18 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb
index 638052a2aa..35ca2dcf2f 100644
--- a/actionpack/lib/action_controller/resources.rb
+++ b/actionpack/lib/action_controller/resources.rb
@@ -34,7 +34,7 @@ module ActionController
end
def nesting_path_prefix
- "#{path_prefix}/#{plural}/:#{singular}_id"
+ "#{path}/:#{singular}_id"
end
private
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