Sha256: 1f964d8ff056b552e08c5fed98f5e2e56d75e1a41460052b93ab54a20c746baf

Contents?: true

Size: 746 Bytes

Versions: 8

Compression:

Stored size: 746 Bytes

Contents

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

class TestExists < ActiveSupport::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_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

8 entries across 8 versions & 2 rubygems

Version Path
composite_primary_keys-3.0.9 test/test_exists.rb
composite_primary_keys-3.0.8 test/test_exists.rb
composite_primary_keys-3.0.7 test/test_exists.rb
composite_primary_keys-3.0.4 test/test_exists.rb
composite_primary_keys-3.0.3 test/test_exists.rb
composite_primary_keys-3.0.0.b3 test/test_exists.rb
composite_primary_keys-3.0.0.b2 test/test_exists.rb
globe-composite_primary_keys-3.0.1 test/test_exists.rb