Sha256: 67ae135cf20615e94338efcf431262082827d5e575590c112e47a10cf5260529

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

require 'abstract_unit'

class TestEqual < ActiveSupport::TestCase
  fixtures :departments

  include CompositePrimaryKeys::Predicates

  def test_or
    dep = Arel::Table.new(:departments)

    predicates = Array.new

    3.times do |i|
      predicates << dep[:id].eq(i)
    end

    pred = cpk_or_predicate(predicates)
    assert_equal('(("departments"."id" = 0) OR ("departments"."id" = 1) OR ("departments"."id" = 2))',
                 pred)
  end

  def test_and
    dep = Arel::Table.new(:departments)

    predicates = Array.new

    3.times do |i|
      predicates << dep[:id].eq(i)
    end

    pred = cpk_and_predicate(predicates)
    assert_equal('"departments"."id" = 0 AND "departments"."id" = 1 AND "departments"."id" = 2',
                pred.to_sql)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
composite_primary_keys-4.0.0.beta7 test/test_predicates.rb