Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
88545353
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
88545353
编写于
6月 03, 2008
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git@github.com:rails/rails
上级
edfa195e
025515b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
4 deletion
+21
-4
actionpack/lib/action_controller/assertions/response_assertions.rb
...k/lib/action_controller/assertions/response_assertions.rb
+1
-1
actionpack/test/controller/action_pack_assertions_test.rb
actionpack/test/controller/action_pack_assertions_test.rb
+20
-3
未找到文件。
actionpack/lib/action_controller/assertions/response_assertions.rb
浏览文件 @
88545353
...
...
@@ -97,7 +97,7 @@ def assert_redirected_to(options = {}, message=nil)
value
[
'controller'
]
=
value
[
'controller'
].
to_s
if
key
==
:actual
&&
value
[
'controller'
].
first
!=
'/'
&&
!
value
[
'controller'
].
include?
(
'/'
)
new_controller_path
=
ActionController
::
Routing
.
controller_relative_to
(
value
[
'controller'
],
@controller
.
class
.
controller_path
)
value
[
'controller'
]
=
new_controller_path
if
value
[
'controller'
]
!=
new_controller_path
&&
ActionController
::
Routing
.
possible_controllers
.
include?
(
new_controller_path
)
value
[
'controller'
]
=
new_controller_path
if
value
[
'controller'
]
!=
new_controller_path
&&
ActionController
::
Routing
.
possible_controllers
.
include?
(
new_controller_path
)
&&
@response
.
redirected_to
.
is_a?
(
Hash
)
end
value
[
'controller'
]
=
value
[
'controller'
][
1
..-
1
]
if
value
[
'controller'
].
first
==
'/'
# strip leading hash
end
...
...
actionpack/test/controller/action_pack_assertions_test.rb
浏览文件 @
88545353
...
...
@@ -137,6 +137,9 @@ def show
end
end
class
UserController
<
ActionController
::
Base
end
module
Admin
class
InnerModuleController
<
ActionController
::
Base
def
index
...
...
@@ -174,7 +177,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
# let's get this party started
def
setup
ActionController
::
Routing
::
Routes
.
reload
ActionController
::
Routing
.
use_controllers!
(
%w(action_pack_assertions admin/inner_module content admin/user)
)
ActionController
::
Routing
.
use_controllers!
(
%w(action_pack_assertions admin/inner_module
user
content admin/user)
)
@controller
=
ActionPackAssertionsController
.
new
@request
,
@response
=
ActionController
::
TestRequest
.
new
,
ActionController
::
TestResponse
.
new
end
...
...
@@ -268,7 +271,7 @@ def test_assert_redirect_to_nested_named_route
assert_redirected_to
admin_inner_module_path
end
end
def
test_assert_redirected_to_top_level_named_route_from_nested_controller
with_routing
do
|
set
|
set
.
draw
do
|
map
|
...
...
@@ -277,11 +280,25 @@ def test_assert_redirected_to_top_level_named_route_from_nested_controller
end
@controller
=
Admin
::
InnerModuleController
.
new
process
:redirect_to_top_level_named_route
#
passes -> assert_redirected_to "http://test.host/action_pack_assertions/foo"
#
assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return
assert_redirected_to
"/action_pack_assertions/foo"
end
end
def
test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces
with_routing
do
|
set
|
set
.
draw
do
|
map
|
# this controller exists in the admin namespace as well which is the only difference from previous test
map
.
top_level
'/user/:id'
,
:controller
=>
'user'
,
:action
=>
'index'
map
.
connect
':controller/:action/:id'
end
@controller
=
Admin
::
InnerModuleController
.
new
process
:redirect_to_top_level_named_route
# assert_redirected_to top_level_url('foo') would pass because of exact match early return
assert_redirected_to
top_level_path
(
'foo'
)
end
end
# -- standard request/response object testing --------------------------------
# make sure that the template objects exist
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录