diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-08 23:35:06 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-08 23:35:06 +0900 |
commit | 952ae3eca77da4632fd20ff040ca8581dbbad25d (patch) | |
tree | 9ab54d8409079421b95a095e1b47e3237352e008 /activerecord/test/cases/adapter_test.rb | |
parent | 5f35c60f848dda275e34bc055f58031c08d7b416 (diff) | |
download | rails-952ae3eca77da4632fd20ff040ca8581dbbad25d.tar.gz rails-952ae3eca77da4632fd20ff040ca8581dbbad25d.tar.bz2 rails-952ae3eca77da4632fd20ff040ca8581dbbad25d.zip |
`supports_xxx?` returns whether a feature is supported by the backend
Rather than a configuration on the connection.
Diffstat (limited to 'activerecord/test/cases/adapter_test.rb')
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
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 |