aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapter_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-08 23:35:06 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-09-08 23:35:06 +0900
commit952ae3eca77da4632fd20ff040ca8581dbbad25d (patch)
tree9ab54d8409079421b95a095e1b47e3237352e008 /activerecord/test/cases/adapter_test.rb
parent5f35c60f848dda275e34bc055f58031c08d7b416 (diff)
downloadrails-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.rb25
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