2016-08-06 13:15:15 -04:00
|
|
|
require "test_helper"
|
|
|
|
require_relative "./common"
|
2016-01-24 05:43:40 -05:00
|
|
|
|
2016-08-06 13:15:15 -04:00
|
|
|
require "active_record"
|
2016-01-24 05:43:40 -05:00
|
|
|
|
|
|
|
class PostgresqlAdapterTest < ActionCable::TestCase
|
|
|
|
include CommonSubscriptionAdapterTest
|
|
|
|
|
|
|
|
def setup
|
2016-08-06 13:15:15 -04:00
|
|
|
database_config = { "adapter" => "postgresql", "database" => "activerecord_unittest" }
|
|
|
|
ar_tests = File.expand_path("../../../activerecord/test", __dir__)
|
2016-01-24 05:43:40 -05:00
|
|
|
if Dir.exist?(ar_tests)
|
2016-08-06 13:15:15 -04:00
|
|
|
require File.join(ar_tests, "config")
|
|
|
|
require File.join(ar_tests, "support/config")
|
|
|
|
local_config = ARTest.config["arunit"]
|
2016-01-24 05:43:40 -05:00
|
|
|
database_config.update local_config if local_config
|
|
|
|
end
|
2016-03-04 01:58:46 -05:00
|
|
|
|
2016-01-24 05:43:40 -05:00
|
|
|
ActiveRecord::Base.establish_connection database_config
|
|
|
|
|
2016-03-04 01:58:46 -05:00
|
|
|
begin
|
|
|
|
ActiveRecord::Base.connection
|
|
|
|
rescue
|
2016-03-26 16:49:18 -04:00
|
|
|
@rx_adapter = @tx_adapter = nil
|
2016-03-04 01:58:46 -05:00
|
|
|
skip "Couldn't connect to PostgreSQL: #{database_config.inspect}"
|
|
|
|
end
|
|
|
|
|
2016-01-24 05:43:40 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
|
|
|
|
|
|
|
ActiveRecord::Base.clear_all_connections!
|
|
|
|
end
|
|
|
|
|
|
|
|
def cable_config
|
2016-08-06 13:15:15 -04:00
|
|
|
{ adapter: "postgresql" }
|
2016-01-24 05:43:40 -05:00
|
|
|
end
|
|
|
|
end
|