diff options
author | Kevin Deisz <kevin.deisz@gmail.com> | 2015-05-28 20:40:27 -0400 |
---|---|---|
committer | Kevin Deisz <kevin.deisz@gmail.com> | 2015-05-28 20:41:03 -0400 |
commit | d909211736b1e85cb011a1a3a87c08d1d1f32a63 (patch) | |
tree | 093ff74c6cddca72964fed20f47542dad37a9ff4 /activesupport/test/core_ext | |
parent | 2f9d88954caf4fd75098e813a3ab8bf50ef6ace4 (diff) | |
download | rails-d909211736b1e85cb011a1a3a87c08d1d1f32a63.tar.gz rails-d909211736b1e85cb011a1a3a87c08d1d1f32a63.tar.bz2 rails-d909211736b1e85cb011a1a3a87c08d1d1f32a63.zip |
Add Enumerable#pluck.
Allows fetching the same values from arrays as from ActiveRecord associations.
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/enumerable_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb index e5d8ae7882..21743cdea5 100644 --- a/activesupport/test/core_ext/enumerable_test.rb +++ b/activesupport/test/core_ext/enumerable_test.rb @@ -110,4 +110,9 @@ class EnumerableTests < ActiveSupport::TestCase assert_equal [1, 2, 4], (1..5).to_set.without(3, 5) assert_equal({foo: 1, baz: 3}, {foo: 1, bar: 2, baz: 3}.without(:bar)) end + + def test_pluck + payments = GenericEnumerable.new([ Payment.new(5), Payment.new(15), Payment.new(10) ]) + assert_equal [5, 15, 10], payments.pluck(:price) + end end |