From 408fe5facc482f84194bbe79865a26b57b2cc883 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 31 May 2006 23:25:36 +0000 Subject: Added Array#to_s(:db) that'll produce a comma-separated list of ids [DHH] Split Grouping into its own file git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4387 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/array_ext_test.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 0d5f58a9be..4cef0120d6 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -13,7 +13,7 @@ class ArrayExtToParamTests < Test::Unit::TestCase end end -class ArrayExtConversionTests < Test::Unit::TestCase +class ArrayExtToSentenceTests < Test::Unit::TestCase def test_plain_array_to_sentence assert_equal "", [].to_sentence assert_equal "one", ['one'].to_sentence @@ -39,6 +39,19 @@ class ArrayExtConversionTests < Test::Unit::TestCase end end +class ArrayExtToSTests < Test::Unit::TestCase + def test_to_s_db + collection = [ + Class.new { def id() 1 end }.new, + Class.new { def id() 2 end }.new, + Class.new { def id() 3 end }.new + ] + + assert_equal "null", [].to_s(:db) + assert_equal "1,2,3", collection.to_s(:db) + end +end + class ArrayExtGroupingTests < Test::Unit::TestCase def test_group_by_with_perfect_fit groups = [] -- cgit v1.2.3