Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
eeb32469
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,发现更多精彩内容 >>
提交
eeb32469
编写于
9月 15, 2010
作者:
S
Sparky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Only add Rack::Cache to the middleware stack if config.action_controller.perform_caching is set.
上级
dd6efe98
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
7 deletion
+50
-7
railties/lib/rails/application.rb
railties/lib/rails/application.rb
+4
-2
railties/test/application/middleware/cache_test.rb
railties/test/application/middleware/cache_test.rb
+15
-1
railties/test/application/middleware_test.rb
railties/test/application/middleware_test.rb
+31
-4
未找到文件。
railties/lib/rails/application.rb
浏览文件 @
eeb32469
...
...
@@ -147,9 +147,11 @@ def config
def
default_middleware_stack
ActionDispatch
::
MiddlewareStack
.
new
.
tap
do
|
middleware
|
r
equire
"action_dispatch/http/rack_cache"
if
config
.
action_dispatch
.
rack_cache
r
ack_cache
=
config
.
action_controller
.
perform_caching
&&
config
.
action_dispatch
.
rack_cache
middleware
.
use
::
Rack
::
Cache
,
config
.
action_dispatch
.
rack_cache
if
config
.
action_dispatch
.
rack_cache
require
"action_dispatch/http/rack_cache"
if
rack_cache
middleware
.
use
::
Rack
::
Cache
,
rack_cache
if
rack_cache
middleware
.
use
::
ActionDispatch
::
Static
,
config
.
static_asset_paths
if
config
.
serve_static_assets
middleware
.
use
::
Rack
::
Lock
if
!
config
.
allow_concurrency
middleware
.
use
::
Rack
::
Runtime
...
...
railties/test/application/middleware/cache_test.rb
浏览文件 @
eeb32469
...
...
@@ -24,7 +24,7 @@ def app(env = "production")
end
def
simple_controller
controller
:
foo
,
<<-
RUBY
controller
:
expires
,
<<-
RUBY
class ExpiresController < ApplicationController
def expires_header
expires_in 10, :public => !params[:private]
...
...
@@ -55,6 +55,20 @@ def render_conditionally(headers)
RUBY
end
def
test_cache_is_disabled_in_dev_mode
simple_controller
app
(
"development"
)
get
"/expires/expires_header"
assert_nil
last_response
.
headers
[
'X-Rack-Cache'
]
body
=
last_response
.
body
get
"/expires/expires_header"
assert_nil
last_response
.
headers
[
'X-Rack-Cache'
]
assert_not_equal
body
,
last_response
.
body
end
def
test_cache_works_with_expires
simple_controller
...
...
railties/test/application/middleware_test.rb
浏览文件 @
eeb32469
...
...
@@ -18,6 +18,33 @@ def app
test
"default middleware stack"
do
boot!
assert_equal
[
"ActionDispatch::Static"
,
"Rack::Lock"
,
"ActiveSupport::Cache::Strategy::LocalCache"
,
"Rack::Runtime"
,
"Rails::Rack::Logger"
,
"ActionDispatch::ShowExceptions"
,
"ActionDispatch::RemoteIp"
,
"Rack::Sendfile"
,
"ActionDispatch::Callbacks"
,
"ActiveRecord::ConnectionAdapters::ConnectionManagement"
,
"ActiveRecord::QueryCache"
,
"ActionDispatch::Cookies"
,
"ActionDispatch::Session::CookieStore"
,
"ActionDispatch::Flash"
,
"ActionDispatch::ParamsParser"
,
"Rack::MethodOverride"
,
"ActionDispatch::Head"
,
"ActionDispatch::BestStandardsSupport"
],
middleware
end
test
"Rack::Cache is present when action_controller.perform_caching is set"
do
add_to_config
"config.action_controller.perform_caching = true"
boot!
assert_equal
[
"Rack::Cache"
,
"ActionDispatch::Static"
,
...
...
@@ -82,24 +109,24 @@ def app
test
"insert middleware after"
do
add_to_config
"config.middleware.insert_after ActionDispatch::Static, Rack::Config"
boot!
assert_equal
"Rack::Config"
,
middleware
.
thir
d
assert_equal
"Rack::Config"
,
middleware
.
secon
d
end
test
"RAILS_CACHE does not respond to middleware"
do
add_to_config
"config.cache_store = :memory_store"
boot!
assert_equal
"Rack::Runtime"
,
middleware
.
fourth
assert_equal
"Rack::Runtime"
,
middleware
.
third
end
test
"RAILS_CACHE does respond to middleware"
do
boot!
assert_equal
"Rack::Runtime"
,
middleware
.
f
if
th
assert_equal
"Rack::Runtime"
,
middleware
.
f
our
th
end
test
"insert middleware before"
do
add_to_config
"config.middleware.insert_before ActionDispatch::Static, Rack::Config"
boot!
assert_equal
"Rack::Config"
,
middleware
.
second
assert_equal
"Rack::Config"
,
middleware
.
first
end
# x_sendfile_header middleware
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录