diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-04 15:13:14 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-04 15:13:14 -0700 |
commit | cc04a4a9037cc91684a99a69d031c04bad1a1467 (patch) | |
tree | 50cbe40267488e99b51bd0e53c5aeb2d84217886 /activerecord/test | |
parent | ffbefc7e55568b0cef79df6ec4b3437c5b6f8bb4 (diff) | |
download | rails-cc04a4a9037cc91684a99a69d031c04bad1a1467.tar.gz rails-cc04a4a9037cc91684a99a69d031c04bad1a1467.tar.bz2 rails-cc04a4a9037cc91684a99a69d031c04bad1a1467.zip |
stop adding singleton methods to the PG connection
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/connection_test.rb | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/connection_test.rb b/activerecord/test/cases/adapters/postgresql/connection_test.rb index 6b726ce875..f482a36d86 100644 --- a/activerecord/test/cases/adapters/postgresql/connection_test.rb +++ b/activerecord/test/cases/adapters/postgresql/connection_test.rb @@ -5,16 +5,31 @@ module ActiveRecord 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 + 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_encoding @@ -47,38 +62,38 @@ module ActiveRecord def test_tables_logs_name @connection.tables('hello') - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end def test_indexes_logs_name @connection.indexes('items', 'hello') - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end def test_table_exists_logs_name @connection.table_exists?('items') - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end def test_table_alias_length_logs_name @connection.instance_variable_set("@table_alias_length", nil) @connection.table_alias_length - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end def test_current_database_logs_name @connection.current_database - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end def test_encoding_logs_name @connection.encoding - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end def test_schema_names_logs_name @connection.schema_names - assert_equal 'SCHEMA', @connection.logged[0][1] + assert_equal 'SCHEMA', @subscriber.logged[0][1] end # Must have with_manual_interventions set to true for this |