summaryrefslogtreecommitdiffstats
path: root/rubygem-activerecord-fix-set-order.patch
blob: efb9ab6a6758e577cff41e2696db1a3af08fbc34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From 55c0b9ff55a4c803ebcab04cd24104783c6c530d Mon Sep 17 00:00:00 2001
From: Evan Phoenix <ephoenix@engineyard.com>
Date: Mon, 22 Mar 2010 09:51:44 -0700
Subject: [PATCH] Don't depend on order of elements in Set

(cherry picked from commit a307fd6bd37d12d8ad6baa7e7fcfd0207e8b354a)
---
 activerecord/test/cases/finder_test.rb |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 871fdc3..8fd7d08 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -494,6 +494,18 @@ class FinderTest < ActiveRecord::TestCase
     assert_kind_of Time, Topic.find(:first, :conditions => ["id = :id", { :id => 1 }]).written_on
   end
 
+  class SimpleEnumerable
+    include Enumerable
+
+    def initialize(ary)
+      @ary = ary
+    end
+
+    def each(&b)
+      @ary.each(&b)
+    end
+  end
+
   def test_bind_enumerable
     quoted_abc = %(#{ActiveRecord::Base.connection.quote('a')},#{ActiveRecord::Base.connection.quote('b')},#{ActiveRecord::Base.connection.quote('c')})
 
@@ -503,12 +515,11 @@ class FinderTest < ActiveRecord::TestCase
     assert_equal '1,2,3', bind(':a', :a => [1, 2, 3])
     assert_equal quoted_abc, bind(':a', :a => %w(a b c)) # '
 
-    require 'set'
-    assert_equal '1,2,3', bind('?', Set.new([1, 2, 3]))
-    assert_equal quoted_abc, bind('?', Set.new(%w(a b c)))
+    assert_equal '1,2,3', bind('?', SimpleEnumerable.new([1, 2, 3]))
+    assert_equal quoted_abc, bind('?', SimpleEnumerable.new(%w(a b c)))
 
-    assert_equal '1,2,3', bind(':a', :a => Set.new([1, 2, 3]))
-    assert_equal quoted_abc, bind(':a', :a => Set.new(%w(a b c))) # '
+    assert_equal '1,2,3', bind(':a', :a => SimpleEnumerable.new([1, 2, 3]))
+    assert_equal quoted_abc, bind(':a', :a => SimpleEnumerable.new(%w(a b c))) # '
   end
 
   def test_bind_empty_enumerable
-- 
1.7.1