Skip to content

Commit

Permalink
Added deprecation warnings because IdentityMap was deprecated.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Aug 28, 2012
1 parent 8333b93 commit 5d54592
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions activerecord/lib/active_record/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "active_record"
require "rails"
require "active_model/railtie"
require "active_support/deprecation"

# For now, action_controller must always be present with
# rails, so let's make sure that it gets required before
Expand Down Expand Up @@ -53,8 +54,11 @@ class Railtie < Rails::Railtie
end

initializer "active_record.identity_map" do |app|
config.app_middleware.insert_after "::ActionDispatch::Callbacks",
"ActiveRecord::IdentityMap::Middleware" if config.active_record.delete(:identity_map)
if config.active_record.delete(:identity_map)
config.app_middleware.insert_after "::ActionDispatch::Callbacks",
"ActiveRecord::IdentityMap::Middleware"
ActiveSupport::Deprecation.warn "IdentityMap is deprecated. We don't support IdentityMap on Rail 4.0"
end
end

initializer "active_record.set_configs" do |app|
Expand Down
13 changes: 10 additions & 3 deletions railties/test/application/middleware_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ def app
end

test "identity map is inserted" do
add_to_config "config.active_record.identity_map = true"
boot!
assert middleware.include?("ActiveRecord::IdentityMap::Middleware")
begin
add_to_config "config.active_record.identity_map = true"
add_to_config "config.active_support.deprecation = :stderr"
old, $stderr = $stderr, StringIO.new
boot!
assert middleware.include?("ActiveRecord::IdentityMap::Middleware")
assert_match(/DEPRECATION WARNING/, $stderr.string)
ensure
$stderr = old
end
end

test "insert middleware before" do
Expand Down

0 comments on commit 5d54592

Please sign in to comment.