aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorjeroeningen <jeroen@jeroen.(none)>2012-05-26 19:17:05 +0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-22 08:35:36 -0300
commit2e379c1e63b3646f9aff4d7e242ca37b4a57f529 (patch)
treef97d1a7c73a65aa476ea8d6ca526d521a58ceef9 /activerecord/test/cases/calculations_test.rb
parent8b173f3bc5484a33ab985fd1a556f1f744e82cd7 (diff)
downloadrails-2e379c1e63b3646f9aff4d7e242ca37b4a57f529.tar.gz
rails-2e379c1e63b3646f9aff4d7e242ca37b4a57f529.tar.bz2
rails-2e379c1e63b3646f9aff4d7e242ca37b4a57f529.zip
ActiveRecord#pluck now accepts multiple columns
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index f748b897ee..e86cf33b66 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -532,7 +532,7 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal [50 + 53 + 55 + 60], Account.pluck('SUM(DISTINCT(credit_limit)) as credit_limit')
end
- def test_pluck_expects_a_single_selection
+ def test_pluck_expects_a_multiple_selection_as_array
assert_raise(ArgumentError) { Account.pluck 'id, credit_limit' }
end
@@ -546,4 +546,19 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal Company.count, ids.length
assert_equal [7], ids.compact
end
+
+ def test_pluck_multiple_columns
+ assert_equal [
+ [1, "The First Topic"], [2, "The Second Topic of the day"],
+ [3, "The Third Topic of the day"], [4, "The Fourth Topic of the day"]
+ ], Topic.order(:id).pluck([:id, :title])
+ assert_equal [
+ [1, "The First Topic", "David"], [2, "The Second Topic of the day", "Mary"],
+ [3, "The Third Topic of the day", "Carl"], [4, "The Fourth Topic of the day", "Carl"]
+ ], Topic.order(:id).pluck([:id, :title, :author_name])
+ assert_equal [
+ [1, "The First Topic"], [2, "The Second Topic of the day"],
+ [3, "The Third Topic of the day"], [4, "The Fourth Topic of the day"]
+ ], Topic.order(:id).pluck(:id, :title)
+ end
end