1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

value on a selected field.
This commit is contained in:
gmile 2011-02-12 14:42:20 +02:00 committed by Aaron Patterson
parent 3331166b48
commit 66a18855ea

View file

@ -1045,6 +1045,28 @@ class FinderTest < ActiveRecord::TestCase
:order => ' author_addresses_authors.id DESC ', :limit => 3).size
end
def test_find_with_nil_inside_set_passed_for_attribute
client_of = Company.find(
:all,
:conditions => {
:client_of => [2, 1, nil],
:name => ['37signals', 'Summit', 'Microsoft'] },
:order => 'client_of DESC'
).map { |x| x.client_of }
assert_equal [2, 1, nil], client_of
end
def test_find_with_nil_inside_set_passed_for_attribute
client_of = Company.find(
:all,
:conditions => { :client_of => [nil] },
:order => 'client_of DESC'
).map { |x| x.client_of }
assert_equal [nil], client_of
end
def test_with_limiting_with_custom_select
posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3, :order => 'posts.id')
assert_equal 3, posts.size