aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-06-06 22:18:13 +0930
committerGitHub <noreply@github.com>2017-06-06 22:18:13 +0930
commitb7d244f52add490da2fec993772089baed0dab98 (patch)
treed7c628117d96d3b7c76678ffaeddaf2a59b6d9a4 /activerecord/test
parente7e9e0722aea751886aeb7e501fadf115e95897e (diff)
parentc40502f9f063baf7fb07ea4203b0b277fddd95a1 (diff)
downloadrails-b7d244f52add490da2fec993772089baed0dab98.tar.gz
rails-b7d244f52add490da2fec993772089baed0dab98.tar.bz2
rails-b7d244f52add490da2fec993772089baed0dab98.zip
Merge pull request #29359 from y-yagi/load_schema_before_assertion
Load schema before assertion
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/calculations_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 21c5c0efee..adfca08289 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -718,21 +718,27 @@ class CalculationsTest < ActiveRecord::TestCase
end
def test_pluck_loaded_relation
+ Company.attribute_names # Load schema information so we don't query below
companies = Company.order(:id).limit(3).load
+
assert_no_queries do
assert_equal ["37signals", "Summit", "Microsoft"], companies.pluck(:name)
end
end
def test_pluck_loaded_relation_multiple_columns
+ Company.attribute_names # Load schema information so we don't query below
companies = Company.order(:id).limit(3).load
+
assert_no_queries do
assert_equal [[1, "37signals"], [2, "Summit"], [3, "Microsoft"]], companies.pluck(:id, :name)
end
end
def test_pluck_loaded_relation_sql_fragment
+ Company.attribute_names # Load schema information so we don't query below
companies = Company.order(:name).limit(3).load
+
assert_queries 1 do
assert_equal ["37signals", "Apex", "Ex Nihilo"], companies.pluck("DISTINCT name")
end