Sha256: 2e44bd65928a1e939f5ffc55ca21b6c16dfcba1d584b4d1898576acdcba7e085

Contents?: true

Size: 640 Bytes

Versions: 3

Compression:

Stored size: 640 Bytes

Contents

describe ActiveHashRelation do
  include Helpers

  context 'primary_key' do
    it "one key" do
      hash = {id: 1}

      query = HelperClass.new.apply_filters(User.all, hash).to_sql
      expected_query = q(
        "SELECT users.* FROM users WHERE (users.id = 1)"
      )

      expect(strip(query)).to eq expected_query.to_s
    end

    it "multiple keys" do
      hash = {id: [1,2,3,4]}

      query = HelperClass.new.apply_filters(User.all, hash).to_sql
      expected_query = q(
        "SELECT users.* FROM users WHERE (users.id IN (1, 2, 3, 4))"
      )

      expect(strip(query)).to eq expected_query.to_s
    end
  end
end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_hash_relation-1.4.1 spec/tests/primary_key_spec.rb
active_hash_relation-1.4.0 spec/tests/primary_key_spec.rb
active_hash_relation-1.2.0 spec/tests/primary_key_spec.rb