Permalink
Browse files

Postgresql: add test case for setting custom libpq connection parameters

  • Loading branch information...
1 parent 8ee6406 commit 8aaf9719dadc3696b939f3429d57973d00df40d9 @larskanis committed Jan 3, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 activerecord/test/cases/adapters/postgresql/connection_test.rb
View
15 activerecord/test/cases/adapters/postgresql/connection_test.rb
@@ -2,6 +2,9 @@
module ActiveRecord
class PostgresqlConnectionTest < ActiveRecord::TestCase
+ class NonExistentTable < ActiveRecord::Base
+ end
+
def setup
super
@connection = ActiveRecord::Base.connection
@@ -10,5 +13,17 @@ def setup
def test_encoding
assert_not_nil @connection.encoding
end
+
+ # Ensure, we can set connection params using the example of Generic
+ # Query Optimizer (geqo). It is 'on' per default.
+ def test_connection_options
+ params = ActiveRecord::Base.connection_config.dup
+ params[:options] = "-c geqo=off"
+ NonExistentTable.establish_connection(params)
+
+ # Verify the connection param has been applied.
+ expect = NonExistentTable.connection.query('show geqo').first.first
+ assert_equal 'off', expect
+ end
end
end

0 comments on commit 8aaf971

Please sign in to comment.