Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6e2a7716
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,体验更适合开发者的 AI 搜索 >>
提交
6e2a7716
编写于
12月 25, 2008
作者:
P
Pratik Naik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Undry ActionController::TestCase#<HTTP_METHODS> for better documentation
上级
e898f82a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
14 deletion
+26
-14
actionpack/lib/action_controller/test_process.rb
actionpack/lib/action_controller/test_process.rb
+25
-12
actionpack/test/controller/caching_test.rb
actionpack/test/controller/caching_test.rb
+1
-2
未找到文件。
actionpack/lib/action_controller/test_process.rb
浏览文件 @
6e2a7716
...
...
@@ -388,20 +388,33 @@ def method_missing(method_name, *args, &block) #:nodoc:
module
TestProcess
def
self
.
included
(
base
)
# execute the request simulating a specific HTTP method and set/volley the response
# TODO: this should be un-DRY'ed for the sake of API documentation.
%w( get post put delete head )
.
each
do
|
method
|
base
.
class_eval
<<-
EOV
,
__FILE__
,
__LINE__
def
#{
method
}
(action, parameters = nil, session = nil, flash = nil)
@request.env['REQUEST_METHOD'] = "
#{
method
.
upcase
}
" if defined?(@request)
process(action, parameters, session, flash)
end
EOV
# Executes a request simulating GET HTTP method and set/volley the response
def
get
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
)
process
(
action
,
parameters
,
session
,
flash
,
"GET"
)
end
# Executes a request simulating POST HTTP method and set/volley the response
def
post
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
)
process
(
action
,
parameters
,
session
,
flash
,
"POST"
)
end
# Executes a request simulating PUT HTTP method and set/volley the response
def
put
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
)
process
(
action
,
parameters
,
session
,
flash
,
"PUT"
)
end
# Executes a request simulating DELETE HTTP method and set/volley the response
def
delete
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
)
process
(
action
,
parameters
,
session
,
flash
,
"DELETE"
)
end
# Executes a request simulating HEAD HTTP method and set/volley the response
def
head
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
)
process
(
action
,
parameters
,
session
,
flash
,
"HEAD"
)
end
end
# execute the request and set/volley the response
def
process
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
)
def
process
(
action
,
parameters
=
nil
,
session
=
nil
,
flash
=
nil
,
http_method
=
'GET'
)
# Sanity check for required instance variables so we can give an
# understandable error message.
%w(@controller @request @response)
.
each
do
|
iv_name
|
...
...
@@ -414,7 +427,7 @@ def process(action, parameters = nil, session = nil, flash = nil)
@response
.
recycle!
@html_document
=
nil
@request
.
env
[
'REQUEST_METHOD'
]
||=
"GET"
@request
.
env
[
'REQUEST_METHOD'
]
=
http_method
@request
.
action
=
action
.
to_s
...
...
actionpack/test/controller/caching_test.rb
浏览文件 @
6e2a7716
...
...
@@ -121,8 +121,7 @@ def test_should_cache_ok_at_custom_path
[
:get
,
:post
,
:put
,
:delete
].
each
do
|
method
|
unless
method
==
:get
and
status
==
:ok
define_method
"test_shouldnt_cache_
#{
method
}
_with_
#{
status
}
_status"
do
@request
.
env
[
'REQUEST_METHOD'
]
=
method
.
to_s
.
upcase
process
status
send
(
method
,
status
)
assert_response
status
assert_page_not_cached
status
,
"
#{
method
}
with
#{
status
}
status shouldn't have been cached"
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录