Sha256: a6ea75a66cc0014bdaaf69b13149a5df5f2d9d39d8021adb25e2364c55a3ef41

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

require 'abstract_unit'
require 'fixtures/article'
require 'fixtures/department'

class TestExists < Test::Unit::TestCase
  fixtures :articles, :departments
  
  def test_single_key_exists_giving_id
    assert Article.exists?(1)
  end
  
  def test_single_key_exists_giving_condition
    assert Article.exists?(['name = ?', 'Article One'])
  end
  
  def test_composite_key_exists_giving_ids_as_string
    assert Department.exists?('1,1,')
  end
  
  def test_composite_key_exists_giving_ids_as_array
    assert Department.exists?([1,1])
    assert_equal(false, Department.exists?([1111,1111]))
  end
  
  def test_composite_key_exists_giving_ids_as_condition
    assert Department.exists?(['department_id = ? and location_id = ?', 1, 1])
    assert_equal(false, Department.exists?(['department_id = ? and location_id = ?', 11111, 11111]))
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
mingusbabcock-composite_primary_keys-2.2.2.1 test/test_exists.rb
tyler-composite_primary_keys-1.1.0 test/test_exists.rb
composite_primary_keys-2.2.2 test/test_exists.rb