diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-01-31 11:17:02 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-01-31 11:17:02 -0800 |
commit | 75de1ce131cd39f68dbe6b68eecf2617a720a8e4 (patch) | |
tree | 93f0001a3363a1367b4412457039f3848bd57fad /activerecord/test | |
parent | d6e41f364a73fb0378dc29d63c15ef7c18b8e18e (diff) | |
parent | 8270e4a8ce8337fca98030953922e5992b06a3dd (diff) | |
download | rails-75de1ce131cd39f68dbe6b68eecf2617a720a8e4.tar.gz rails-75de1ce131cd39f68dbe6b68eecf2617a720a8e4.tar.bz2 rails-75de1ce131cd39f68dbe6b68eecf2617a720a8e4.zip |
Merge pull request #4805 from xuanxu/none_and_null_object_pattern
Added `none` query method to return zero records.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 5e19465253..0471d03f3b 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -215,6 +215,19 @@ class RelationTest < ActiveRecord::TestCase assert_equal [2, 4, 6, 8, 10], even_ids.sort end + def test_none + assert_no_queries do + assert_equal [], Developer.none + assert_equal [], Developer.scoped.none + end + end + + def test_none_chainable + assert_no_queries do + assert_equal [], Developer.none.where(:name => 'David') + end + end + def test_joins_with_nil_argument assert_nothing_raised { DependentFirm.joins(nil).first } end |