Browse files

stop adding singleton methods to the mysql2 adapter

  • Loading branch information...
1 parent cc04a4a commit 6828ae7779c0ff1be321408027851b73a964593b @tenderlove tenderlove committed Oct 4, 2013
View
14 activerecord/test/cases/adapters/mysql2/connection_test.rb
@@ -3,14 +3,14 @@
class MysqlConnectionTest < ActiveRecord::TestCase
def setup
super
+ @subscriber = SQLSubscriber.new
+ ActiveSupport::Notifications.subscribe('sql.active_record', @subscriber)
@connection = ActiveRecord::Base.connection
- @connection.extend(LogIntercepter)
- @connection.intercepted = true
end
def teardown
- @connection.intercepted = false
- @connection.logged = []
+ ActiveSupport::Notifications.unsubscribe(@subscriber)
+ super
end
def test_no_automatic_reconnection_after_timeout
@@ -72,14 +72,14 @@ def test_mysql_set_session_variable_to_default
def test_logs_name_show_variable
@connection.show_variable 'foo'
- assert_equal "SCHEMA", @connection.logged[0][1]
+ assert_equal "SCHEMA", @subscriber.logged[0][1]
end
def test_logs_name_rename_column_sql
@connection.execute "CREATE TABLE `bar_baz` (`foo` varchar(255))"
- @connection.logged = []
+ @subscriber.logged.clear
@connection.send(:rename_column_sql, 'bar_baz', 'foo', 'foo2')
- assert_equal "SCHEMA", @connection.logged[0][1]
+ assert_equal "SCHEMA", @subscriber.logged[0][1]
ensure
@connection.execute "DROP TABLE `bar_baz`"
end
View
15 activerecord/test/cases/adapters/postgresql/connection_test.rb
@@ -5,21 +5,6 @@ class PostgresqlConnectionTest < ActiveRecord::TestCase
class NonExistentTable < ActiveRecord::Base
end
- class SQLSubscriber
- attr_reader :logged
-
- def initialize
- @logged = []
- end
-
- def start(name, id, payload)
- @logged << [payload[:sql], payload[:name], payload[:binds]]
- end
-
- def finish(name, id, payload)
- end
- end
-
def setup
super
@subscriber = SQLSubscriber.new
View
15 activerecord/test/cases/helper.rb
@@ -134,6 +134,21 @@ def log(sql, name = 'SQL', binds = [], &block)
end
end
+class SQLSubscriber
+ attr_reader :logged
+
+ def initialize
+ @logged = []
+ end
+
+ def start(name, id, payload)
+ @logged << [payload[:sql], payload[:name], payload[:binds]]
+ end
+
+ def finish(name, id, payload); end
+end
+
+
module InTimeZone
private

0 comments on commit 6828ae7

Please sign in to comment.