Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
acb371ca
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,发现更多精彩内容 >>
提交
acb371ca
编写于
8月 05, 2014
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
call the routes method on engines
if we access the instance, we can free up lots of codes
上级
9a36fac8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
74 deletion
+37
-74
actionpack/test/dispatch/prefix_generation_test.rb
actionpack/test/dispatch/prefix_generation_test.rb
+37
-74
未找到文件。
actionpack/test/dispatch/prefix_generation_test.rb
浏览文件 @
acb371ca
...
...
@@ -25,65 +25,43 @@ class WithMountedEngine < ActionDispatch::IntegrationTest
include
Rack
::
Test
::
Methods
class
BlogEngine
<
Rails
::
Engine
@routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
.
tap
{
|
routes
|
routes
.
draw
do
get
"/posts/:id"
,
:to
=>
"inside_engine_generating#show"
,
:as
=>
:post
get
"/posts"
,
:to
=>
"inside_engine_generating#index"
,
:as
=>
:posts
get
"/url_to_application"
,
:to
=>
"inside_engine_generating#url_to_application"
get
"/polymorphic_path_for_engine"
,
:to
=>
"inside_engine_generating#polymorphic_path_for_engine"
get
"/conflicting_url"
,
:to
=>
"inside_engine_generating#conflicting"
get
"/foo"
,
:to
=>
"never#invoked"
,
:as
=>
:named_helper_that_should_be_invoked_only_in_respond_to_test
get
"/relative_path_root"
,
:to
=>
redirect
(
""
)
get
"/relative_path_redirect"
,
:to
=>
redirect
(
"foo"
)
get
"/relative_option_root"
,
:to
=>
redirect
(
:path
=>
""
)
get
"/relative_option_redirect"
,
:to
=>
redirect
(
:path
=>
"foo"
)
get
"/relative_custom_root"
,
:to
=>
redirect
{
|
params
,
request
|
""
}
get
"/relative_custom_redirect"
,
:to
=>
redirect
{
|
params
,
request
|
"foo"
}
get
"/absolute_path_root"
,
:to
=>
redirect
(
"/"
)
get
"/absolute_path_redirect"
,
:to
=>
redirect
(
"/foo"
)
get
"/absolute_option_root"
,
:to
=>
redirect
(
:path
=>
"/"
)
get
"/absolute_option_redirect"
,
:to
=>
redirect
(
:path
=>
"/foo"
)
get
"/absolute_custom_root"
,
:to
=>
redirect
{
|
params
,
request
|
"/"
}
get
"/absolute_custom_redirect"
,
:to
=>
redirect
{
|
params
,
request
|
"/foo"
}
end
}
def
self
.
routes
@routes
end
def
self
.
call
(
env
)
env
[
'action_dispatch.routes'
]
=
routes
routes
.
call
(
env
)
routes
.
draw
do
get
"/posts/:id"
,
:to
=>
"inside_engine_generating#show"
,
:as
=>
:post
get
"/posts"
,
:to
=>
"inside_engine_generating#index"
,
:as
=>
:posts
get
"/url_to_application"
,
:to
=>
"inside_engine_generating#url_to_application"
get
"/polymorphic_path_for_engine"
,
:to
=>
"inside_engine_generating#polymorphic_path_for_engine"
get
"/conflicting_url"
,
:to
=>
"inside_engine_generating#conflicting"
get
"/foo"
,
:to
=>
"never#invoked"
,
:as
=>
:named_helper_that_should_be_invoked_only_in_respond_to_test
get
"/relative_path_root"
,
:to
=>
redirect
(
""
)
get
"/relative_path_redirect"
,
:to
=>
redirect
(
"foo"
)
get
"/relative_option_root"
,
:to
=>
redirect
(
:path
=>
""
)
get
"/relative_option_redirect"
,
:to
=>
redirect
(
:path
=>
"foo"
)
get
"/relative_custom_root"
,
:to
=>
redirect
{
|
params
,
request
|
""
}
get
"/relative_custom_redirect"
,
:to
=>
redirect
{
|
params
,
request
|
"foo"
}
get
"/absolute_path_root"
,
:to
=>
redirect
(
"/"
)
get
"/absolute_path_redirect"
,
:to
=>
redirect
(
"/foo"
)
get
"/absolute_option_root"
,
:to
=>
redirect
(
:path
=>
"/"
)
get
"/absolute_option_redirect"
,
:to
=>
redirect
(
:path
=>
"/foo"
)
get
"/absolute_custom_root"
,
:to
=>
redirect
{
|
params
,
request
|
"/"
}
get
"/absolute_custom_redirect"
,
:to
=>
redirect
{
|
params
,
request
|
"/foo"
}
end
end
class
RailsApplication
<
Rails
::
Engine
@routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
.
tap
{
|
routes
|
routes
.
draw
do
scope
"/:omg"
,
:omg
=>
"awesome"
do
mount
BlogEngine
=>
"/blog"
,
:as
=>
"blog_engine"
end
get
"/posts/:id"
,
:to
=>
"outside_engine_generating#post"
,
:as
=>
:post
get
"/generate"
,
:to
=>
"outside_engine_generating#index"
get
"/polymorphic_path_for_app"
,
:to
=>
"outside_engine_generating#polymorphic_path_for_app"
get
"/polymorphic_path_for_engine"
,
:to
=>
"outside_engine_generating#polymorphic_path_for_engine"
get
"/polymorphic_with_url_for"
,
:to
=>
"outside_engine_generating#polymorphic_with_url_for"
get
"/conflicting_url"
,
:to
=>
"outside_engine_generating#conflicting"
get
"/ivar_usage"
,
:to
=>
"outside_engine_generating#ivar_usage"
root
:to
=>
"outside_engine_generating#index"
routes
.
draw
do
scope
"/:omg"
,
:omg
=>
"awesome"
do
mount
BlogEngine
=>
"/blog"
,
:as
=>
"blog_engine"
end
}
def
self
.
routes
@routes
end
def
self
.
call
(
env
)
env
[
'action_dispatch.routes'
]
=
routes
routes
.
call
(
env
)
get
"/posts/:id"
,
:to
=>
"outside_engine_generating#post"
,
:as
=>
:post
get
"/generate"
,
:to
=>
"outside_engine_generating#index"
get
"/polymorphic_path_for_app"
,
:to
=>
"outside_engine_generating#polymorphic_path_for_app"
get
"/polymorphic_path_for_engine"
,
:to
=>
"outside_engine_generating#polymorphic_path_for_engine"
get
"/polymorphic_with_url_for"
,
:to
=>
"outside_engine_generating#polymorphic_with_url_for"
get
"/conflicting_url"
,
:to
=>
"outside_engine_generating#conflicting"
get
"/ivar_usage"
,
:to
=>
"outside_engine_generating#ivar_usage"
root
:to
=>
"outside_engine_generating#index"
end
end
...
...
@@ -159,7 +137,7 @@ class AppObject
end
def
app
RailsApplication
RailsApplication
.
instance
end
attr_reader
:engine_object
,
:app_object
...
...
@@ -389,27 +367,12 @@ def self.call(env)
end
end
class
RailsApplication
def
self
.
routes
@routes
||=
begin
routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
routes
.
draw
do
mount
BlogEngine
=>
"/"
end
routes
end
end
def
self
.
call
(
env
)
env
[
'action_dispatch.routes'
]
=
routes
routes
.
call
(
env
)
class
RailsApplication
<
Rails
::
Engine
routes
.
draw
do
mount
BlogEngine
=>
"/"
end
end
# force draw
RailsApplication
.
routes
class
::
PostsController
<
ActionController
::
Base
include
BlogEngine
.
routes
.
url_helpers
include
RailsApplication
.
routes
.
mounted_helpers
...
...
@@ -420,7 +383,7 @@ def show
end
def
app
RailsApplication
RailsApplication
.
instance
end
test
"generating path inside engine"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录