Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f28d073a
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 搜索 >>
提交
f28d073a
编写于
12月 21, 2016
作者:
J
Julia López
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix with_routing when testing api only controllers
上级
8c547838
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
2 deletion
+33
-2
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+4
-0
actionpack/lib/action_dispatch/testing/assertions/routing.rb
actionpack/lib/action_dispatch/testing/assertions/routing.rb
+5
-2
actionpack/test/controller/action_pack_assertions_test.rb
actionpack/test/controller/action_pack_assertions_test.rb
+24
-0
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
f28d073a
*
Make
`with_routing`
test helper work when testing controllers inheriting from
`ActionController::API`
*Julia López*
*
Use accept header in integration tests with
`as: :json`
Instead of appending the `format` to the request path, Rails will figure
...
...
actionpack/lib/action_dispatch/testing/assertions/routing.rb
浏览文件 @
f28d073a
...
...
@@ -152,8 +152,11 @@ def with_routing
_routes
=
@routes
@controller
.
singleton_class
.
include
(
_routes
.
url_helpers
)
@controller
.
view_context_class
=
Class
.
new
(
@controller
.
view_context_class
)
do
include
_routes
.
url_helpers
if
@controller
.
respond_to?
:view_context_class
@controller
.
view_context_class
=
Class
.
new
(
@controller
.
view_context_class
)
do
include
_routes
.
url_helpers
end
end
end
yield
@routes
...
...
actionpack/test/controller/action_pack_assertions_test.rb
浏览文件 @
f28d073a
...
...
@@ -128,6 +128,16 @@ def redirect_to_top_level_named_route
end
end
class
ApiOnlyController
<
ActionController
::
API
def
nothing
head
:ok
end
def
redirect_to_new_route
redirect_to
new_route_url
end
end
class
ActionPackAssertionsControllerTest
<
ActionController
::
TestCase
def
test_render_file_absolute_path
get
:render_file_absolute_path
...
...
@@ -170,6 +180,20 @@ def test_string_constraint
end
end
def
test_with_routing_works_with_api_only_controllers
@controller
=
ApiOnlyController
.
new
with_routing
do
|
set
|
set
.
draw
do
get
"new_route"
,
to:
"api_only#nothing"
get
"redirect_to_new_route"
,
to:
"api_only#redirect_to_new_route"
end
process
:redirect_to_new_route
assert_redirected_to
"http://test.host/new_route"
end
end
def
test_assert_redirect_to_named_route_failure
with_routing
do
|
set
|
set
.
draw
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录