diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-07 00:49:36 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-07 01:06:42 -0200 |
commit | 6ba0f975d5d2867f80bcf8a809b1337c8f369383 (patch) | |
tree | 2f28f62f231bec5d035cc37f793996bad8110011 /activerecord/test | |
parent | 23b9cc84230042aaf7f824d70e010d7678350ec3 (diff) | |
download | rails-6ba0f975d5d2867f80bcf8a809b1337c8f369383.tar.gz rails-6ba0f975d5d2867f80bcf8a809b1337c8f369383.tar.bz2 rails-6ba0f975d5d2867f80bcf8a809b1337c8f369383.zip |
Ensure there won't be any regression with where(nil) calls
Consider this scenario:
if params[:foo]
conditions = { foo: true }
end
foos = Foo.where(conditions).order(:id)
When params[:foo] is nil, this would call:
foos = Foo.where(nil).order(:id)
In this scenario, we want Foo.where(conditions) to be the same as calling
Foo.all, otherwise we'd get a "NoMethodError order for WhereChain".
Related to #8332.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index e8cc6558ca..d25aca760f 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -299,7 +299,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end def test_find_with_blank_conditions - [[], {}, ""].each do |blank| + [[], {}, nil, ""].each do |blank| assert_equal 2, Firm.all.merge!(:order => "id").first.clients.where(blank).to_a.size end end |