diff options
author | jeroeningen <jeroen@jeroen.(none)> | 2012-05-26 19:17:05 +0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-22 08:35:36 -0300 |
commit | 2e379c1e63b3646f9aff4d7e242ca37b4a57f529 (patch) | |
tree | f97d1a7c73a65aa476ea8d6ca526d521a58ceef9 /activerecord/test/cases | |
parent | 8b173f3bc5484a33ab985fd1a556f1f744e82cd7 (diff) | |
download | rails-2e379c1e63b3646f9aff4d7e242ca37b4a57f529.tar.gz rails-2e379c1e63b3646f9aff4d7e242ca37b4a57f529.tar.bz2 rails-2e379c1e63b3646f9aff4d7e242ca37b4a57f529.zip |
ActiveRecord#pluck now accepts multiple columns
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 17 |
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 |