]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/composite_primary_keys-2.2.2/test/test_exists.rb
Normalise line endings.
[rails.git] / vendor / gems / composite_primary_keys-2.2.2 / test / test_exists.rb
1 require 'abstract_unit'
2 require 'fixtures/article'
3 require 'fixtures/department'
4
5 class TestExists < Test::Unit::TestCase
6   fixtures :articles, :departments
7   
8   def test_single_key_exists_giving_id
9     assert Article.exists?(1)
10   end
11   
12   def test_single_key_exists_giving_condition
13     assert Article.exists?(['name = ?', 'Article One'])
14   end
15   
16   def test_composite_key_exists_giving_ids_as_string
17     assert Department.exists?('1,1,')
18   end
19   
20   def test_composite_key_exists_giving_ids_as_array
21     assert Department.exists?([1,1])
22     assert_equal(false, Department.exists?([1111,1111]))
23   end
24   
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]))
28   end
29 end