aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-07 00:38:51 -0700
committerJon Leighton <j@jonathanleighton.com>2011-09-07 00:38:51 -0700
commitdb8d54ebf5102d2f30c0c332ea852ad284702ef3 (patch)
tree5700b21c7dc088f9506f49e76dfb249826004e2f /activerecord/test/cases
parent4edf6ea0eae9cb8be46a2e963e047eb89a0f5531 (diff)
parentd48dd18bb2a3d0c46708a9ee217909783b997cb2 (diff)
downloadrails-db8d54ebf5102d2f30c0c332ea852ad284702ef3.tar.gz
rails-db8d54ebf5102d2f30c0c332ea852ad284702ef3.tar.bz2
rails-db8d54ebf5102d2f30c0c332ea852ad284702ef3.zip
Merge pull request #2485 from akaspick/exists_fix
fix exists? to return false if passed nil (which may come from a missing
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/finder_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index d840d38678..47bf2d007f 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -48,6 +48,15 @@ class FinderTest < ActiveRecord::TestCase
assert Topic.exists?
end
+ # exists? should handle nil for id's that come from URLs and always return false
+ # (example: Topic.exists?(params[:id])) where params[:id] is nil
+ def test_exists_with_nil_arg
+ assert !Topic.exists?(nil)
+ assert Topic.exists?
+ assert !Topic.first.replies.exists?(nil)
+ assert Topic.first.replies.exists?
+ end
+
def test_does_not_exist_with_empty_table_and_no_args_given
Topic.delete_all
assert !Topic.exists?