aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-12-27 18:00:49 +0530
committerPratik Naik <pratiknaik@gmail.com>2009-12-27 18:00:49 +0530
commit2c8f83556bf3ec9861315e11bc070753ef6bd97c (patch)
tree12e4d36f96644cf8f3493e57b9e7ee31c659a799 /activerecord/test/cases
parentb31233485b2ec7be96279448f77c860b0e94279b (diff)
downloadrails-2c8f83556bf3ec9861315e11bc070753ef6bd97c.tar.gz
rails-2c8f83556bf3ec9861315e11bc070753ef6bd97c.tar.bz2
rails-2c8f83556bf3ec9861315e11bc070753ef6bd97c.zip
Add relation.exists?
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 9c5a38a399..d65fb5095c 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -298,4 +298,15 @@ class RelationTest < ActiveRecord::TestCase
assert_raises(ActiveRecord::RecordNotFound) { authors.find(['invalid', 'oops']) }
end
+ def test_exists
+ davids = Author.where(:name => 'David')
+ assert davids.exists?
+ assert davids.exists?(authors(:david).id)
+ assert ! davids.exists?(authors(:mary).id)
+ assert ! davids.exists?("hax'id")
+
+ fake = Author.where(:name => 'fake author')
+ assert ! fake.exists?
+ assert ! fake.exists?(authors(:david).id)
+ end
end