提交 c9417dce 编写于 作者: J Jeremy Kemper

Nested resource testing.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4643 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 a247d721
......@@ -34,7 +34,7 @@ def member_path
end
def nesting_path_prefix
"#{path_prefix}/#{plural}/:#{singular}_id"
"#{path}/:#{singular}_id"
end
private
......
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 @@ def test_with_new_action
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册