Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d919fd88
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,发现更多精彩内容 >>
提交
d919fd88
编写于
8月 08, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11352 from xaviershay/dispatcher-api
Allow a custom dispatcher to be provided to routing.
上级
12f08acb
2992b1c0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
21 deletion
+23
-21
actionpack/lib/action_dispatch/routing/route_set.rb
actionpack/lib/action_dispatch/routing/route_set.rb
+9
-4
actionpack/test/abstract_unit.rb
actionpack/test/abstract_unit.rb
+4
-8
actionpack/test/dispatch/mapper_test.rb
actionpack/test/dispatch/mapper_test.rb
+4
-0
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+6
-9
未找到文件。
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
d919fd88
...
...
@@ -62,13 +62,17 @@ def controller(params, default_controller=true)
raise
ActionController
::
RoutingError
,
e
.
message
,
e
.
backtrace
if
default_controller
end
private
protected
attr_reader
:controller_class_names
def
controller_reference
(
controller_param
)
const_name
=
@
controller_class_names
[
controller_param
]
||=
"
#{
controller_param
.
camelize
}
Controller"
const_name
=
controller_class_names
[
controller_param
]
||=
"
#{
controller_param
.
camelize
}
Controller"
ActiveSupport
::
Dependencies
.
constantize
(
const_name
)
end
private
def
dispatch
(
controller
,
action
,
req
)
controller
.
action
(
action
).
call
(
req
.
env
)
end
...
...
@@ -313,7 +317,7 @@ def define_url_helper(mod, route, name, opts, route_key, url_strategy)
attr_accessor
:formatter
,
:set
,
:named_routes
,
:default_scope
,
:router
attr_accessor
:disable_clear_and_finalize
,
:resources_path_names
attr_accessor
:default_url_options
attr_accessor
:default_url_options
,
:dispatcher_class
attr_reader
:env_key
alias
:routes
:set
...
...
@@ -356,6 +360,7 @@ def initialize(config = DEFAULT_CONFIG)
@set
=
Journey
::
Routes
.
new
@router
=
Journey
::
Router
.
new
@set
@formatter
=
Journey
::
Formatter
.
new
@set
@dispatcher_class
=
Routing
::
RouteSet
::
Dispatcher
end
def
relative_url_root
...
...
@@ -414,7 +419,7 @@ def clear!
end
def
dispatcher
(
defaults
)
Routing
::
RouteSet
::
Dispatcher
.
new
(
defaults
)
dispatcher_class
.
new
(
defaults
)
end
module
MountedHelpers
...
...
actionpack/test/abstract_unit.rb
浏览文件 @
d919fd88
...
...
@@ -130,14 +130,10 @@ def dispatch(controller, action, env)
end
end
def
self
.
stub_controllers
old_dispatcher
=
ActionDispatch
::
Routing
::
RouteSet
::
Dispatcher
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
remove_const
:Dispatcher
}
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
const_set
:Dispatcher
,
StubDispatcher
}
yield
ActionDispatch
::
Routing
::
RouteSet
.
new
ensure
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
remove_const
:Dispatcher
}
ActionDispatch
::
Routing
::
RouteSet
.
module_eval
{
const_set
:Dispatcher
,
old_dispatcher
}
def
self
.
stub_controllers
(
config
=
nil
)
route_set
=
ActionDispatch
::
Routing
::
RouteSet
.
new
(
*
[
config
].
compact
)
route_set
.
dispatcher_class
=
StubDispatcher
yield
route_set
end
def
with_routing
(
&
block
)
...
...
actionpack/test/dispatch/mapper_test.rb
浏览文件 @
d919fd88
...
...
@@ -19,6 +19,10 @@ def request_class
ActionDispatch
::
Request
end
def
dispatcher_class
RouteSet
::
Dispatcher
end
def
add_route
(
*
args
)
routes
<<
args
end
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
d919fd88
...
...
@@ -168,12 +168,10 @@ def test_session_singleton_resource
end
def
test_session_singleton_resource_for_api_app
self
.
class
.
stub_controllers
do
|
_
|
config
=
ActionDispatch
::
Routing
::
RouteSet
::
Config
.
new
config
.
api_only
=
true
routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
(
config
)
config
=
ActionDispatch
::
Routing
::
RouteSet
::
Config
.
new
config
.
api_only
=
true
self
.
class
.
stub_controllers
(
config
)
do
|
routes
|
routes
.
draw
do
resource
:session
do
get
:create
...
...
@@ -550,11 +548,10 @@ def test_projects
end
def
test_projects_for_api_app
self
.
class
.
stub_controllers
do
|
_
|
config
=
ActionDispatch
::
Routing
::
RouteSet
::
Config
.
new
config
.
api_only
=
true
config
=
ActionDispatch
::
Routing
::
RouteSet
::
Config
.
new
config
.
api_only
=
true
routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
(
config
)
self
.
class
.
stub_controllers
(
config
)
do
|
routes
|
routes
.
draw
do
resources
:projects
,
controller: :project
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录