Sha256: fc9ad5636650847739a7f002dc676e5669a1b3d8743f3547289ae21355c7c12e

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

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

    5.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 OR "departments"."id" = 3 OR "departments"."id" = 4',
                 pred)
  end

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

    predicates = Array.new

    5.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 AND "departments"."id" = 3 AND "departments"."id" = 4',
                pred.to_sql)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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