From 952ae3eca77da4632fd20ff040ca8581dbbad25d Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 8 Sep 2018 23:35:06 +0900 Subject: `supports_xxx?` returns whether a feature is supported by the backend Rather than a configuration on the connection. --- activerecord/test/cases/adapter_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'activerecord/test/cases/adapter_test.rb') diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 1c461a0459..a93e5e2b40 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "cases/helper" +require "support/connection_helper" require "models/book" require "models/post" require "models/author" @@ -446,3 +447,27 @@ module ActiveRecord end end end + +if ActiveRecord::Base.connection.supports_advisory_locks? + class AdvisoryLocksEnabledTest < ActiveRecord::TestCase + include ConnectionHelper + + def test_advisory_locks_enabled? + assert ActiveRecord::Base.connection.advisory_locks_enabled? + + run_without_connection do |orig_connection| + ActiveRecord::Base.establish_connection( + orig_connection.merge(advisory_locks: false) + ) + + assert_not ActiveRecord::Base.connection.advisory_locks_enabled? + + ActiveRecord::Base.establish_connection( + orig_connection.merge(advisory_locks: true) + ) + + assert ActiveRecord::Base.connection.advisory_locks_enabled? + end + end + end +end -- cgit v1.2.3