Skip to content
This repository
Browse code

Test that passing nil member of array in conditions retrieves records…

… with nil

value on a selected field.
  • Loading branch information...
commit 66a18855eafa71c11a37333ce1314889cbd0f742 1 parent 3331166
Pirogov Evgenij authored February 12, 2011 tenderlove committed April 29, 2011

Showing 1 changed file with 22 additions and 0 deletions. Show diff stats Hide diff stats

  1. 22  activerecord/test/cases/finder_test.rb
22  activerecord/test/cases/finder_test.rb
@@ -1045,6 +1045,28 @@ def test_find_with_order_on_included_associations_with_construct_finder_sql_for_
1045 1045
                               :order => ' author_addresses_authors.id DESC ', :limit => 3).size
1046 1046
   end
1047 1047
 
  1048
+  def test_find_with_nil_inside_set_passed_for_attribute
  1049
+    client_of = Company.find(
  1050
+      :all,
  1051
+      :conditions => {
  1052
+        :client_of => [2, 1, nil],
  1053
+        :name => ['37signals', 'Summit', 'Microsoft'] },
  1054
+      :order => 'client_of DESC'
  1055
+    ).map { |x| x.client_of }
  1056
+
  1057
+    assert_equal [2, 1, nil], client_of
  1058
+  end
  1059
+
  1060
+  def test_find_with_nil_inside_set_passed_for_attribute
  1061
+    client_of = Company.find(
  1062
+      :all,
  1063
+      :conditions => { :client_of => [nil] },
  1064
+      :order => 'client_of DESC'
  1065
+    ).map { |x| x.client_of }
  1066
+
  1067
+    assert_equal [nil], client_of
  1068
+  end
  1069
+
1048 1070
   def test_with_limiting_with_custom_select
1049 1071
     posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3, :order => 'posts.id')
1050 1072
     assert_equal 3, posts.size

0 notes on commit 66a1885

Please sign in to comment.
Something went wrong with that request. Please try again.