Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a6757a02
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,发现更多精彩内容 >>
提交
a6757a02
编写于
9月 26, 2009
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move middleware and route configuration from AC::Dispatcher to Rails application object
上级
14866fa3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
30 addition
and
22 deletion
+30
-22
actionpack/lib/action_controller/dispatch/dispatcher.rb
actionpack/lib/action_controller/dispatch/dispatcher.rb
+3
-8
actionpack/lib/action_controller/testing/process.rb
actionpack/lib/action_controller/testing/process.rb
+0
-2
actionpack/lib/action_dispatch/testing/integration.rb
actionpack/lib/action_dispatch/testing/integration.rb
+3
-2
actionpack/test/controller/dispatcher_test.rb
actionpack/test/controller/dispatcher_test.rb
+5
-7
railties/lib/rails/application.rb
railties/lib/rails/application.rb
+5
-1
railties/lib/rails/console_app.rb
railties/lib/rails/console_app.rb
+1
-1
railties/lib/rails/initializer.rb
railties/lib/rails/initializer.rb
+1
-1
railties/test/console_app_test.rb
railties/test/console_app_test.rb
+6
-0
railties/test/fcgi_dispatcher_test.rb
railties/test/fcgi_dispatcher_test.rb
+6
-0
未找到文件。
actionpack/lib/action_controller/dispatch/dispatcher.rb
浏览文件 @
a6757a02
...
...
@@ -7,12 +7,6 @@ class Dispatcher
cattr_accessor
:prepare_each_request
self
.
prepare_each_request
=
false
cattr_accessor
:router
self
.
router
=
Routing
::
Routes
cattr_accessor
:middleware
self
.
middleware
=
ActionDispatch
::
MiddlewareStack
.
new
class
<<
self
def
define_dispatcher_callbacks
(
cache_classes
)
unless
cache_classes
...
...
@@ -21,7 +15,7 @@ def define_dispatcher_callbacks(cache_classes)
# Development mode callbacks
ActionDispatch
::
Callbacks
.
before_dispatch
do
|
app
|
ActionController
::
Dispatcher
.
router
.
reload
ActionController
::
Routing
::
Routes
.
reload
end
ActionDispatch
::
Callbacks
.
after_dispatch
do
...
...
@@ -55,7 +49,8 @@ def define_dispatcher_callbacks(cache_classes)
:to
=>
ActionDispatch
::
Callbacks
def
new
@@middleware
.
build
(
@@router
)
# DEPRECATE Rails application fallback
Rails
.
application
end
end
end
...
...
actionpack/lib/action_controller/testing/process.rb
浏览文件 @
a6757a02
...
...
@@ -99,7 +99,6 @@ def with_routing
temporary_routes
=
ActionController
::
Routing
::
RouteSet
.
new
ActionController
::
Routing
.
module_eval
{
const_set
:Routes
,
temporary_routes
}
ActionController
::
Dispatcher
.
router
=
temporary_routes
yield
temporary_routes
ensure
...
...
@@ -107,7 +106,6 @@ def with_routing
ActionController
::
Routing
.
module_eval
{
remove_const
:Routes
}
end
ActionController
::
Routing
.
const_set
(
:Routes
,
real_routes
)
if
real_routes
ActionController
::
Dispatcher
.
router
=
ActionController
::
Routing
::
Routes
end
end
end
actionpack/lib/action_dispatch/testing/integration.rb
浏览文件 @
a6757a02
...
...
@@ -484,8 +484,9 @@ class IntegrationTest < ActiveSupport::TestCase
@@app
=
nil
def
self
.
app
# DEPRECATE AC::Dispatcher fallback
@@app
||
ActionController
::
Dispatcher
.
new
# DEPRECATE Rails application fallback
# This should be set by the initializer
@@app
||
(
defined?
(
Rails
.
application
)
&&
Rails
.
application
)
||
nil
end
def
self
.
app
=
(
app
)
...
...
actionpack/test/controller/dispatcher_test.rb
浏览文件 @
a6757a02
...
...
@@ -14,14 +14,12 @@ def setup
ActionDispatch
::
Callbacks
.
reset_callbacks
(
:prepare
)
ActionDispatch
::
Callbacks
.
reset_callbacks
(
:call
)
@old_router
,
Dispatcher
.
router
=
Dispatcher
.
router
,
mock
()
Dispatcher
.
router
.
stubs
(
:call
).
returns
([
200
,
{},
'response'
])
Dispatcher
.
router
.
stubs
(
:reload
)
ActionController
::
Routing
::
Routes
.
stubs
(
:call
).
returns
([
200
,
{},
'response'
])
ActionController
::
Routing
::
Routes
.
stubs
(
:reload
)
Dispatcher
.
stubs
(
:require_dependency
)
end
def
teardown
Dispatcher
.
router
=
@old_router
ENV
.
delete
'REQUEST_METHOD'
end
...
...
@@ -31,12 +29,12 @@ def test_clears_dependencies_after_dispatch_if_in_loading_mode
end
def
test_reloads_routes_before_dispatch_if_in_loading_mode
Dispatcher
.
router
.
expects
(
:reload
).
once
ActionController
::
Routing
::
Routes
.
expects
(
:reload
).
once
dispatch
(
false
)
end
def
test_leaves_dependencies_after_dispatch_if_not_in_loading_mode
Dispatcher
.
router
.
expects
(
:reload
).
never
ActionController
::
Routing
::
Routes
.
expects
(
:reload
).
never
ActiveSupport
::
Dependencies
.
expects
(
:clear
).
never
dispatch
...
...
@@ -78,7 +76,7 @@ def dispatch(cache_classes = true)
ActionController
::
Dispatcher
.
prepare_each_request
=
false
Dispatcher
.
define_dispatcher_callbacks
(
cache_classes
)
@dispatcher
||=
ActionDispatch
::
Callbacks
.
new
(
Dispatcher
.
router
)
@dispatcher
||=
ActionDispatch
::
Callbacks
.
new
(
ActionController
::
Routing
::
Routes
)
@dispatcher
.
call
({
'rack.input'
=>
StringIO
.
new
(
''
),
'action_dispatch.show_exceptions'
=>
false
})
end
...
...
railties/lib/rails/application.rb
浏览文件 @
a6757a02
module
Rails
class
Application
attr_accessor
:middleware
,
:routes
def
initialize
@app
=
ActionController
::
Dispatcher
.
new
@middleware
=
ActionDispatch
::
MiddlewareStack
.
new
@routes
=
ActionController
::
Routing
::
Routes
end
def
call
(
env
)
@app
||=
middleware
.
build
(
@routes
)
@app
.
call
(
env
)
end
end
...
...
railties/lib/rails/console_app.rb
浏览文件 @
a6757a02
...
...
@@ -27,6 +27,6 @@ def new_session
def
reload!
puts
"Reloading..."
ActionDispatch
::
Callbacks
.
new
(
lambda
{},
true
)
ActionController
::
Dispatcher
.
router
.
reload
ActionController
::
Routing
::
Routes
.
reload
true
end
railties/lib/rails/initializer.rb
浏览文件 @
a6757a02
...
...
@@ -608,8 +608,8 @@ def self.run(initializer = nil, config = nil)
Initializer
.
default
.
add
:build_application
do
if
configuration
.
frameworks
.
include?
(
:action_controller
)
ActionController
::
Dispatcher
.
middleware
=
configuration
.
middleware
Rails
.
application
=
Rails
::
Application
.
new
Rails
.
application
.
middleware
=
configuration
.
middleware
end
end
end
railties/test/console_app_test.rb
浏览文件 @
a6757a02
...
...
@@ -5,6 +5,12 @@
require
'rails/dispatcher'
require
'rails/console_app'
module
Rails
def
self
.
application
ActionController
::
Routing
::
Routes
end
end
# console_app sets Test::Unit.run to work around the at_exit hook in test/unit, which kills IRB
if
Test
::
Unit
.
respond_to?
(
:run
=
)
Test
::
Unit
.
run
=
false
...
...
railties/test/fcgi_dispatcher_test.rb
浏览文件 @
a6757a02
...
...
@@ -5,6 +5,12 @@
require
'action_controller'
require
'rails/fcgi_handler'
module
Rails
def
self
.
application
ActionController
::
Routing
::
Routes
end
end
class
RailsFCGIHandlerTest
<
Test
::
Unit
::
TestCase
def
setup
@log
=
StringIO
.
new
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录