From 2f944123f32ad37efc84f13de25350beb7f8fed6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 17 Mar 2005 14:12:25 +0000 Subject: Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@913 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/finder_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index a5eaca039e..3b239b581c 100755 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -10,6 +10,13 @@ class FinderTest < Test::Unit::TestCase assert_equal(@topics["first"]["title"], Topic.find(1).title) end + def test_exists + assert (Topic.exists?(1)) + assert !(Topic.exists?(45)) + assert !(Topic.exists?("foo")) + assert !(Topic.exists?([1,2])) + end + def test_find_by_array_of_one_id assert_kind_of(Array, Topic.find([ 1 ])) assert_equal(1, Topic.find([ 1 ]).length) -- cgit v1.2.3