Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
7591e8c1
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,发现更多精彩内容 >>
提交
7591e8c1
编写于
5月 20, 2014
作者:
Y
Yves Senn
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15182 from zuhao/refactor_actionpack_respond_with_test_2
Un-define :to_json for Customer class after stubbing.
上级
00d1b132
f0440205
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
4 deletion
+10
-4
actionpack/test/controller/mime/respond_with_test.rb
actionpack/test/controller/mime/respond_with_test.rb
+10
-4
未找到文件。
actionpack/test/controller/mime/respond_with_test.rb
浏览文件 @
7591e8c1
...
...
@@ -2,6 +2,10 @@
require
'controller/fake_models'
class
RespondWithController
<
ActionController
::
Base
class
CustomerWithJson
<
Customer
def
to_json
;
super
;
end
end
respond_to
:html
,
:json
,
:touch
respond_to
:xml
,
:except
=>
:using_resource_with_block
respond_to
:js
,
:only
=>
[
:using_resource_with_block
,
:using_resource
,
'using_hash_resource'
]
...
...
@@ -38,6 +42,10 @@ def using_resource_with_status_and_location
respond_with
(
resource
,
:location
=>
"http://test.host/"
,
:status
=>
:created
)
end
def
using_resource_with_json
respond_with
(
CustomerWithJson
.
new
(
"david"
,
request
.
delete?
?
nil
:
13
))
end
def
using_invalid_resource_with_template
respond_with
(
resource
)
end
...
...
@@ -380,9 +388,8 @@ def test_using_resource_for_put_with_xml_yields_no_content_on_success
end
def
test_using_resource_for_put_with_json_yields_no_content_on_success
Customer
.
any_instance
.
stubs
(
:to_json
).
returns
(
'{"name": "David"}'
)
@request
.
accept
=
"application/json"
put
:using_resource
put
:using_resource
_with_json
assert_equal
"application/json"
,
@response
.
content_type
assert_equal
204
,
@response
.
status
assert_equal
""
,
@response
.
body
...
...
@@ -431,10 +438,9 @@ def test_using_resource_for_delete_with_xml_yields_no_content_on_success
end
def
test_using_resource_for_delete_with_json_yields_no_content_on_success
Customer
.
any_instance
.
stubs
(
:to_json
).
returns
(
'{"name": "David"}'
)
Customer
.
any_instance
.
stubs
(
:destroyed?
).
returns
(
true
)
@request
.
accept
=
"application/json"
delete
:using_resource
delete
:using_resource
_with_json
assert_equal
"application/json"
,
@response
.
content_type
assert_equal
204
,
@response
.
status
assert_equal
""
,
@response
.
body
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录