aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAndrew Kaspick <andrew@redlinesoftware.com>2011-08-10 12:55:29 -0500
committerAndrew Kaspick <andrew@redlinesoftware.com>2011-08-10 12:55:29 -0500
commitd48dd18bb2a3d0c46708a9ee217909783b997cb2 (patch)
tree6485c4d04da48ec5339dff401c471b9784f9ea2a /activerecord/test
parentbb4f687bc670932f93a7befe07bfb2859a61411a (diff)
downloadrails-d48dd18bb2a3d0c46708a9ee217909783b997cb2.tar.gz
rails-d48dd18bb2a3d0c46708a9ee217909783b997cb2.tar.bz2
rails-d48dd18bb2a3d0c46708a9ee217909783b997cb2.zip
fix exists? to return false if passed nil (which may come from a missing URL param)
Diffstat (limited to 'activerecord/test')
-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 5dc5f99582..4c6f8b9699 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?