Sha256: 801030b3cb140902256d768b2853477712c0d95199803132c8ac88044dafc96f

Contents?: true

Size: 780 Bytes

Versions: 3

Compression:

Stored size: 780 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

3 entries across 3 versions & 1 rubygems

Version Path
composite_primary_keys-4.0.0 test/test_predicates.rb
composite_primary_keys-4.0.0.beta9 test/test_predicates.rb
composite_primary_keys-4.0.0.beta8 test/test_predicates.rb