aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-06-01 12:40:19 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-06-01 12:40:19 -0300
commit4e63bde623a0478ec55bcbfbe1afd8b4938148c8 (patch)
treea72e1caa12f5c7db65851147c5a1da370025783b /activesupport/test/core_ext
parentbdfc662a1195d13e3ef78cc8e79df8a8a2e3ca97 (diff)
parent777fa257aaa962bf67f6e5522efaa420ea7dc88b (diff)
downloadrails-4e63bde623a0478ec55bcbfbe1afd8b4938148c8.tar.gz
rails-4e63bde623a0478ec55bcbfbe1afd8b4938148c8.tar.bz2
rails-4e63bde623a0478ec55bcbfbe1afd8b4938148c8.zip
Merge pull request #20362 from kddeisz/enumerable_pluck
Allow Enumerable#pluck to take a splat.
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 21743cdea5..f09b7d8850 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -3,6 +3,8 @@ require 'active_support/core_ext/array'
require 'active_support/core_ext/enumerable'
Payment = Struct.new(:price)
+ExpandedPayment = Struct.new(:dollars, :cents)
+
class SummablePayment < Payment
def +(p) self.class.new(price + p.price) end
end
@@ -114,5 +116,12 @@ class EnumerableTests < ActiveSupport::TestCase
def test_pluck
payments = GenericEnumerable.new([ Payment.new(5), Payment.new(15), Payment.new(10) ])
assert_equal [5, 15, 10], payments.pluck(:price)
+
+ payments = GenericEnumerable.new([
+ ExpandedPayment.new(5, 99),
+ ExpandedPayment.new(15, 0),
+ ExpandedPayment.new(10, 50)
+ ])
+ assert_equal [[5, 99], [15, 0], [10, 50]], payments.pluck(:dollars, :cents)
end
end