1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't load IdentityMap middleware if not enabled. Simplify middleware.

This commit is contained in:
Emilio Tagua 2010-10-15 17:32:18 -03:00
parent 48edab9ba0
commit 69b627ef67
3 changed files with 13 additions and 5 deletions

View file

@ -98,8 +98,9 @@ module ActiveRecord
end
def call(env)
ActiveRecord::IdentityMap.enabled? ?
ActiveRecord::IdentityMap.use { @app.call(env) } : @app.call(env)
ActiveRecord::IdentityMap.use do
@app.call(env)
end
end
end
end

View file

@ -22,9 +22,6 @@ module ActiveRecord
config.app_middleware.insert_after "::ActionDispatch::Callbacks",
"ActiveRecord::ConnectionAdapters::ConnectionManagement"
config.app_middleware.insert_after "::ActionDispatch::Callbacks",
"ActiveRecord::IdentityMap::Middleware"
rake_tasks do
load "active_record/railties/databases.rake"
end
@ -81,6 +78,11 @@ module ActiveRecord
end
end
initializer "active_record.identity_map" do |app|
config.app_middleware.insert_after "::ActionDispatch::Callbacks",
"ActiveRecord::IdentityMap::Middleware" if ActiveRecord::IdentityMap.enabled?
end
config.after_initialize do
ActiveSupport.on_load(:active_record) do
instantiate_observers

View file

@ -107,6 +107,11 @@ module ApplicationTests
assert_equal "Rack::Runtime", middleware.fourth
end
test "identity map is inserted" do
boot!
assert_equal "ActiveRecord::IdentityMap::Middleware", middleware[9]
end
test "insert middleware before" do
add_to_config "config.middleware.insert_before ActionDispatch::Static, Rack::Config"
boot!