Skip to content

Commit

Permalink
Merge pull request rails#27109 from prathamesh-sonpatki/fix-prepared-…
Browse files Browse the repository at this point in the history
…statements-test

Fix tests for prepared_statements: false and queries hitting `#select_all`
  • Loading branch information
kaspth authored Nov 19, 2016
2 parents 4aacace + 7b6b52d commit 1cf9956
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ class PreparedStatementsTest < ActiveRecord::PostgreSQLTestCase
fixtures :developers

def setup
@default_prepared_statements = ActiveRecord::Base.connection.instance_variable_get("@prepared_statements")
ActiveRecord::Base.connection.instance_variable_set("@prepared_statements", false)
@conn = ActiveRecord::Base.establish_connection :arunit_with_prepared_statements
end

def teardown
ActiveRecord::Base.connection.instance_variable_set("@prepared_statements", @default_prepared_statements)
@conn.release_connection
ActiveRecord::Base.establish_connection :arunit
end

def test_nothing_raised_with_falsy_prepared_statements
assert_nothing_raised do
Developer.where(id: 1)
Developer.where(id: 1).to_a
end
end
end
3 changes: 3 additions & 0 deletions activerecord/test/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ connections:
postgresql:
arunit:
min_messages: warning
arunit_without_prepared_statements:
min_messages: warning
prepared_statements: false
arunit2:
min_messages: warning

Expand Down
3 changes: 2 additions & 1 deletion activerecord/test/support/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def read_config

def expand_config(config)
config["connections"].each do |adapter, connection|
dbs = [["arunit", "activerecord_unittest"], ["arunit2", "activerecord_unittest2"]]
dbs = [["arunit", "activerecord_unittest"], ["arunit2", "activerecord_unittest2"],
["arunit_with_prepared_statements", "activerecord_unittest"]]
dbs.each do |name, dbname|
unless connection[name].is_a?(Hash)
connection[name] = { "database" => connection[name] }
Expand Down

0 comments on commit 1cf9956

Please sign in to comment.