Sha256: 0d410e999217af3e14777cad352e4dde59e7f194e9c732ef5b0dc0c5aeda0a84

Contents?: true

Size: 1.13 KB

Versions: 65

Compression:

Stored size: 1.13 KB

Contents

require File.expand_path('../abstract_unit', __FILE__)

class TestExists < ActiveSupport::TestCase
  fixtures :articles, :departments, :capitols
  
  def test_id
    assert(Article.exists?(1))
    assert(!Article.exists?(-1))
  end

  def test_array
    assert(Article.exists?(['name = ?', 'Article One']))
    assert(!Article.exists?(['name = ?', 'Article -1']))
  end

  def test_hash
    assert(Article.exists?('name' => 'Article One'))
    assert(!Article.exists?('name' => 'Article -1'))
  end

  def test_cpk_id
    assert(Department.exists?(CompositePrimaryKeys::CompositeKeys.new([1,1])))
    assert(!Department.exists?(CompositePrimaryKeys::CompositeKeys.new([1,-1])))
  end

  def test_cpk_array_id
    assert(Department.exists?([1,1]))
    assert(!Department.exists?([1,-1]))
  end

  def test_cpk_array_condition
    assert(Department.exists?(['department_id = ? and location_id = ?', 1, 1]))
    assert(!Department.exists?(['department_id = ? and location_id = ?', 1, -1]))
  end

  def test_cpk_array_string_id
    assert(Capitol.exists?(['The Netherlands', 'Amsterdam']))
    assert(!Capitol.exists?(['The Netherlands', 'Paris']))
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
composite_primary_keys-9.0.9 test/test_exists.rb
composite_primary_keys-11.0.0.rc2 test/test_exists.rb
composite_primary_keys-10.0.3 test/test_exists.rb
composite_primary_keys-11.0.0.rc1 test/test_exists.rb
composite_primary_keys-11.0.0.beta4 test/test_exists.rb
composite_primary_keys-11.0.0.beta3 test/test_exists.rb
composite_primary_keys-11.0.0.beta2 test/test_exists.rb
composite_primary_keys-11.0.0.beta1 test/test_exists.rb
composite_primary_keys-10.0.2 test/test_exists.rb
composite_primary_keys-10.0.1 test/test_exists.rb
composite_primary_keys-9.0.8 test/test_exists.rb
composite_primary_keys-10.0.0 test/test_exists.rb
composite_primary_keys-9.0.7 test/test_exists.rb
composite_primary_keys-8.1.6 test/test_exists.rb
composite_primary_keys-9.0.6 test/test_exists.rb
composite_primary_keys-9.0.5 test/test_exists.rb
composite_primary_keys-8.1.5 test/test_exists.rb
composite_primary_keys-9.0.4 test/test_exists.rb
composite_primary_keys-9.0.2 test/test_exists.rb
composite_primary_keys-9.0.1 test/test_exists.rb