Sha256: 0685bf137df50318eb5faff70dc0f92335e16336955b8455c47fcedd96f45e9e

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

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

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(with_quoted_identifiers('(("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(with_quoted_identifiers('"departments"."id" = 0 AND "departments"."id" = 1 AND "departments"."id" = 2'),
                pred.to_sql)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
composite_primary_keys-5.0.0.rc1 test/test_predicates.rb
composite_primary_keys-4.1.2 test/test_predicates.rb