Sha256: a7111c760c07dad2c1d0e7a3ba8254728b8ba8747ef143ee04c53b80828d1180

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 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])
  end
  
  def test_composite_key_exists_giving_ids_as_condition
    assert Department.exists?(['department_id = ? and location_id = ?', 1, 1])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
composite_primary_keys-2.2.1 test/test_exists.rb