aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorWill Bryant <will.bryant@gmail.com>2009-02-11 14:49:01 +1300
committerJeremy Kemper <jeremy@bitsweat.net>2009-02-10 18:03:33 -0800
commit1a2a71333f197e98d1cd7fe380d613cbada4446b (patch)
tree7e82866fd3af0945580c0fc0e8bc0e86d2abd91f /activesupport/test
parentff3fb6c5f3b2a0592189545f6f24ef759df6a12e (diff)
downloadrails-1a2a71333f197e98d1cd7fe380d613cbada4446b.tar.gz
rails-1a2a71333f197e98d1cd7fe380d613cbada4446b.tar.bz2
rails-1a2a71333f197e98d1cd7fe380d613cbada4446b.zip
Array#wrap should use #to_ary so association collections and named scopes are not re-wrapped
[#1935 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/array_ext_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb
index a90d6891cf..367f0e0027 100644
--- a/activesupport/test/core_ext/array_ext_test.rb
+++ b/activesupport/test/core_ext/array_ext_test.rb
@@ -304,6 +304,12 @@ class ArrayExtRandomTests < Test::Unit::TestCase
end
class ArrayWrapperTests < Test::Unit::TestCase
+ class FakeCollection
+ def to_ary
+ ["foo", "bar"]
+ end
+ end
+
def test_array
ary = %w(foo bar)
assert_same ary, Array.wrap(ary)
@@ -325,4 +331,8 @@ class ArrayWrapperTests < Test::Unit::TestCase
def test_string_with_newline
assert_equal ["foo\nbar"], Array.wrap("foo\nbar")
end
+
+ def test_object_with_to_ary
+ assert_equal ["foo", "bar"], Array.wrap(FakeCollection.new)
+ end
end