Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
47fe14bf
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,发现更多精彩内容 >>
提交
47fe14bf
编写于
2月 26, 2010
作者:
C
Carlhuda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Silence test deprecation warnings
上级
bae691f6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
17 deletion
+56
-17
actionpack/test/controller/base_test.rb
actionpack/test/controller/base_test.rb
+55
-16
actionpack/test/template/url_helper_test.rb
actionpack/test/template/url_helper_test.rb
+1
-1
未找到文件。
actionpack/test/controller/base_test.rb
浏览文件 @
47fe14bf
...
...
@@ -66,6 +66,16 @@ def default_url_options(options = nil)
end
end
class
UrlOptionsController
<
ActionController
::
Base
def
from_view
render
:inline
=>
"<%=
#{
params
[
:route
]
}
%>"
end
def
url_options
super
.
merge
(
:host
=>
'www.override.com'
,
:action
=>
'new'
,
:locale
=>
'en'
)
end
end
class
ControllerClassTests
<
ActiveSupport
::
TestCase
def
test_controller_path
assert_equal
'empty'
,
EmptyController
.
controller_path
...
...
@@ -162,8 +172,8 @@ def test_get_on_hidden_should_fail
end
end
class
Default
UrlOptionsTest
<
ActionController
::
TestCase
tests
Default
UrlOptionsController
class
UrlOptionsTest
<
ActionController
::
TestCase
tests
UrlOptionsController
def
setup
super
...
...
@@ -174,7 +184,7 @@ def setup
def
test_default_url_options_are_used_if_set
with_routing
do
|
set
|
set
.
draw
do
|
map
|
match
'from_view'
,
:to
=>
'
default_
url_options#from_view'
,
:as
=>
:from_view
match
'from_view'
,
:to
=>
'url_options#from_view'
,
:as
=>
:from_view
match
':controller/:action'
end
...
...
@@ -184,6 +194,33 @@ def test_default_url_options_are_used_if_set
assert_equal
'http://www.override.com/from_view?locale=en'
,
@controller
.
send
(
:from_view_url
)
assert_equal
'http://www.override.com/default_url_options/new?locale=en'
,
@controller
.
url_for
(
:controller
=>
'default_url_options'
)
end
end
end
class
DefaultUrlOptionsTest
<
ActionController
::
TestCase
tests
DefaultUrlOptionsController
def
setup
super
@request
.
host
=
'www.example.com'
rescue_action_in_public!
end
def
test_default_url_options_are_used_if_set
with_routing
do
|
set
|
set
.
draw
do
|
map
|
match
'from_view'
,
:to
=>
'default_url_options#from_view'
,
:as
=>
:from_view
match
':controller/:action'
end
assert_deprecated
do
get
:from_view
,
:route
=>
"from_view_url"
assert_equal
'http://www.override.com/from_view?locale=en'
,
@response
.
body
assert_equal
'http://www.override.com/from_view?locale=en'
,
@controller
.
send
(
:from_view_url
)
assert_equal
'http://www.override.com/default_url_options/new?locale=en'
,
@controller
.
url_for
(
:controller
=>
'default_url_options'
)
end
end
end
def
test_default_url_options_are_used_in_non_positional_parameters
...
...
@@ -195,19 +232,21 @@ def test_default_url_options_are_used_in_non_positional_parameters
match
':controller/:action'
end
get
:from_view
,
:route
=>
"description_path(1)"
assert_equal
'/en/descriptions/1'
,
@response
.
body
assert_equal
'/en/descriptions'
,
@controller
.
send
(
:descriptions_path
)
assert_equal
'/pl/descriptions'
,
@controller
.
send
(
:descriptions_path
,
"pl"
)
assert_equal
'/pl/descriptions'
,
@controller
.
send
(
:descriptions_path
,
:locale
=>
"pl"
)
assert_equal
'/pl/descriptions.xml'
,
@controller
.
send
(
:descriptions_path
,
"pl"
,
"xml"
)
assert_equal
'/en/descriptions.xml'
,
@controller
.
send
(
:descriptions_path
,
:format
=>
"xml"
)
assert_equal
'/en/descriptions/1'
,
@controller
.
send
(
:description_path
,
1
)
assert_equal
'/pl/descriptions/1'
,
@controller
.
send
(
:description_path
,
"pl"
,
1
)
assert_equal
'/pl/descriptions/1'
,
@controller
.
send
(
:description_path
,
1
,
:locale
=>
"pl"
)
assert_equal
'/pl/descriptions/1.xml'
,
@controller
.
send
(
:description_path
,
"pl"
,
1
,
"xml"
)
assert_equal
'/en/descriptions/1.xml'
,
@controller
.
send
(
:description_path
,
1
,
:format
=>
"xml"
)
assert_deprecated
do
get
:from_view
,
:route
=>
"description_path(1)"
assert_equal
'/en/descriptions/1'
,
@response
.
body
assert_equal
'/en/descriptions'
,
@controller
.
send
(
:descriptions_path
)
assert_equal
'/pl/descriptions'
,
@controller
.
send
(
:descriptions_path
,
"pl"
)
assert_equal
'/pl/descriptions'
,
@controller
.
send
(
:descriptions_path
,
:locale
=>
"pl"
)
assert_equal
'/pl/descriptions.xml'
,
@controller
.
send
(
:descriptions_path
,
"pl"
,
"xml"
)
assert_equal
'/en/descriptions.xml'
,
@controller
.
send
(
:descriptions_path
,
:format
=>
"xml"
)
assert_equal
'/en/descriptions/1'
,
@controller
.
send
(
:description_path
,
1
)
assert_equal
'/pl/descriptions/1'
,
@controller
.
send
(
:description_path
,
"pl"
,
1
)
assert_equal
'/pl/descriptions/1'
,
@controller
.
send
(
:description_path
,
1
,
:locale
=>
"pl"
)
assert_equal
'/pl/descriptions/1.xml'
,
@controller
.
send
(
:description_path
,
"pl"
,
1
,
"xml"
)
assert_equal
'/en/descriptions/1.xml'
,
@controller
.
send
(
:description_path
,
1
,
:format
=>
"xml"
)
end
end
end
...
...
actionpack/test/template/url_helper_test.rb
浏览文件 @
47fe14bf
...
...
@@ -426,7 +426,7 @@ def default_url_options(options = nil)
end
with_url_helper_routing
do
get
:show_named_route
,
:kind
=>
'url'
assert_deprecated
{
get
:show_named_route
,
:kind
=>
'url'
}
assert_equal
'http://testtwo.host/url_helper_controller_test/url_helper/show_named_route'
,
@response
.
body
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录