1 require 'abstract_unit'
2 require 'fixtures/article'
3 require 'fixtures/department'
5 class TestExists < Test::Unit::TestCase
6 fixtures :articles, :departments
8 def test_single_key_exists_giving_id
9 assert Article.exists?(1)
12 def test_single_key_exists_giving_condition
13 assert Article.exists?(['name = ?', 'Article One'])
16 def test_composite_key_exists_giving_ids_as_string
17 assert Department.exists?('1,1,')
20 def test_composite_key_exists_giving_ids_as_array
21 assert Department.exists?([1,1])
22 assert_equal(false, Department.exists?([1111,1111]))
25 def test_composite_key_exists_giving_ids_as_condition
26 assert Department.exists?(['department_id = ? and location_id = ?', 1, 1])
27 assert_equal(false, Department.exists?(['department_id = ? and location_id = ?', 11111, 11111]))