1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/test/subscription_adapter/postgresql_test.rb
Kasper Timm Hansen dacfdf03d3 Cable: Shush pop warnings when skipping Postgres tests.
`skip` raises an exception to abort the execution of the test, so
`super` would never be called and thus `@rx_adapter` and `@tx_adapter`
would never have been defined at the time of teardown.

Define them just before skipping and zap the warnings.
2016-03-26 21:49:18 +01:00

40 lines
971 B
Ruby

require 'test_helper'
require_relative './common'
require 'active_record'
class PostgresqlAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
def setup
database_config = { 'adapter' => 'postgresql', 'database' => 'activerecord_unittest' }
ar_tests = File.expand_path('../../../activerecord/test', __dir__)
if Dir.exist?(ar_tests)
require File.join(ar_tests, 'config')
require File.join(ar_tests, 'support/config')
local_config = ARTest.config['arunit']
database_config.update local_config if local_config
end
ActiveRecord::Base.establish_connection database_config
begin
ActiveRecord::Base.connection
rescue
@rx_adapter = @tx_adapter = nil
skip "Couldn't connect to PostgreSQL: #{database_config.inspect}"
end
super
end
def teardown
super
ActiveRecord::Base.clear_all_connections!
end
def cable_config
{ adapter: 'postgresql' }
end
end