Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
312f4332
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,发现更多精彩内容 >>
提交
312f4332
编写于
6月 19, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clear DescendantsTracker on each request.
上级
d430db9f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
81 addition
and
7 deletion
+81
-7
actionpack/lib/action_dispatch/middleware/callbacks.rb
actionpack/lib/action_dispatch/middleware/callbacks.rb
+4
-4
activerecord/lib/active_record/railtie.rb
activerecord/lib/active_record/railtie.rb
+0
-1
railties/lib/rails/application/bootstrap.rb
railties/lib/rails/application/bootstrap.rb
+2
-0
railties/test/application/initializers/load_path_test.rb
railties/test/application/initializers/load_path_test.rb
+1
-1
railties/test/application/loading_test.rb
railties/test/application/loading_test.rb
+73
-0
railties/test/application/rake_test.rb
railties/test/application/rake_test.rb
+1
-1
未找到文件。
actionpack/lib/action_dispatch/middleware/callbacks.rb
浏览文件 @
312f4332
...
...
@@ -8,7 +8,7 @@ module ActionDispatch
class
Callbacks
include
ActiveSupport
::
Callbacks
define_callbacks
:call
,
:
terminator
=>
"result == false"
,
:
rescuable
=>
true
define_callbacks
:call
,
:rescuable
=>
true
define_callbacks
:prepare
,
:scope
=>
:name
# Add a preparation callback. Preparation callbacks are run before every
...
...
@@ -37,12 +37,12 @@ def self.after(*args, &block)
def
initialize
(
app
,
prepare_each_request
=
false
)
@app
,
@prepare_each_request
=
app
,
prepare_each_request
run_callbacks
(
:prepare
)
_run_prepare_callbacks
end
def
call
(
env
)
run_callbacks
(
:call
)
do
run_callbacks
(
:prepare
)
if
@prepare_each_request
_run_call_callbacks
do
_run_prepare_callbacks
if
@prepare_each_request
@app
.
call
(
env
)
end
end
...
...
activerecord/lib/active_record/railtie.rb
浏览文件 @
312f4332
...
...
@@ -68,7 +68,6 @@ class Railtie < Rails::Railtie
unless
app
.
config
.
cache_classes
ActiveSupport
.
on_load
(
:active_record
)
do
ActionDispatch
::
Callbacks
.
after
do
ActiveRecord
::
Base
.
reset_subclasses
ActiveRecord
::
Base
.
clear_reloadable_connections!
end
end
...
...
railties/lib/rails/application/bootstrap.rb
浏览文件 @
312f4332
require
"active_support/notifications"
require
"active_support/descendants_tracker"
module
Rails
class
Application
...
...
@@ -55,6 +56,7 @@ module Bootstrap
initializer
:set_clear_dependencies_hook
do
unless
config
.
cache_classes
ActionDispatch
::
Callbacks
.
after
do
ActiveSupport
::
DescendantsTracker
.
clear
ActiveSupport
::
Dependencies
.
clear
end
end
...
...
railties/test/application/initializers/load_path_test.rb
浏览文件 @
312f4332
...
...
@@ -19,7 +19,7 @@ def setup
assert
$:
.
include?
(
"
#{
app_path
}
/app/models"
)
end
test
"initializing an application a
dds lib path on inheritance hook
"
do
test
"initializing an application a
llows to load code on lib path inside application class definitation
"
do
app_file
"lib/foo.rb"
,
<<-
RUBY
module Foo; end
RUBY
...
...
railties/test/application/
model_initialization
_test.rb
→
railties/test/application/
loading
_test.rb
浏览文件 @
312f4332
require
'isolation/abstract_unit'
class
Post
Test
<
Test
::
Unit
::
TestCase
class
Loading
Test
<
Test
::
Unit
::
TestCase
include
ActiveSupport
::
Testing
::
Isolation
def
setup
...
...
@@ -8,14 +8,60 @@ def setup
boot_rails
end
def
test_reload_should_reload_constants
def
app
@app
||=
Rails
.
application
end
def
test_load_should_load_constants
app_file
"app/models/post.rb"
,
<<-
MODEL
class Post < ActiveRecord::Base
validates_acceptance_of :title, :accept => "omg"
end
MODEL
require
"
#{
rails_root
}
/config/environment"
setup_ar!
p
=
Post
.
create
(
:title
=>
'omg'
)
assert_equal
1
,
Post
.
count
assert_equal
'omg'
,
p
.
title
p
=
Post
.
first
assert_equal
'omg'
,
p
.
title
end
def
test_descendants_are_cleaned_on_each_request_without_cache_classes
add_to_config
<<-
RUBY
config.cache_classes = false
RUBY
app_file
"app/models/post.rb"
,
<<-
MODEL
class Post < ActiveRecord::Base
end
MODEL
app_file
'config/routes.rb'
,
<<-
RUBY
AppTemplate::Application.routes.draw do |map|
match '/load', :to => lambda { |env| [200, {}, Post.all] }
match '/unload', :to => lambda { |env| [200, {}, []] }
end
RUBY
require
'rack/test'
extend
Rack
::
Test
::
Methods
require
"
#{
rails_root
}
/config/environment"
setup_ar!
assert_equal
[],
ActiveRecord
::
Base
.
descendants
get
"/load"
assert_equal
[
Post
],
ActiveRecord
::
Base
.
descendants
get
"/unload"
assert_equal
[],
ActiveRecord
::
Base
.
descendants
end
protected
def
setup_ar!
ActiveRecord
::
Base
.
establish_connection
(
:adapter
=>
"sqlite3"
,
:database
=>
":memory:"
)
ActiveRecord
::
Migration
.
verbose
=
false
ActiveRecord
::
Schema
.
define
(
:version
=>
1
)
do
...
...
@@ -23,11 +69,5 @@ class Post < ActiveRecord::Base
t
.
string
:title
end
end
p
=
Post
.
create
(
:title
=>
'omg'
)
assert_equal
1
,
Post
.
count
assert_equal
'omg'
,
p
.
title
p
=
Post
.
first
assert_equal
'omg'
,
p
.
title
end
end
railties/test/application/rake_test.rb
浏览文件 @
312f4332
...
...
@@ -9,7 +9,7 @@ def setup
boot_rails
FileUtils
.
rm_rf
(
"
#{
app_path
}
/config/environments"
)
end
def
test_gems_tasks_are_loaded_first_than_application_ones
app_file
"lib/tasks/app.rake"
,
<<-
RUBY
$task_loaded = Rake::Task.task_defined?("db:create:all")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录