From 8ca93c78832f4fdc78320e3f73ffd07bb71ce196 Mon Sep 17 00:00:00 2001 From: kennyj Date: Mon, 23 Jul 2012 00:46:00 +0900 Subject: Restore connection_id on error. --- activerecord/test/cases/query_cache_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index 83e207a260..2d778e9e90 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -39,6 +39,18 @@ class QueryCacheTest < ActiveRecord::TestCase assert ActiveRecord::Base.connection.query_cache_enabled, 'cache on' end + def test_exceptional_middleware_assigns_original_connection_id_on_error + connection_id = ActiveRecord::Base.connection_id + + mw = ActiveRecord::QueryCache.new lambda { |env| + ActiveRecord::Base.connection_id = self.object_id + raise "lol borked" + } + assert_raises(RuntimeError) { mw.call({}) } + + assert_equal connection_id, ActiveRecord::Base.connection_id + end + def test_middleware_delegates called = false mw = ActiveRecord::QueryCache.new lambda { |env| -- cgit v1.2.3