Sha256: db7d2f52fb4edd969b905145d017b54869d0e4566eb330fa03e945283e212fa8

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

describe ActiveHashRelation do
  include Helpers

  context 'booleans' do
    it "one boolean where clause" do
      hash = {admin: false}

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

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

    it "multi boolean where clauses" do
      hash = {admin: false, verified: true}

      query = HelperClass.new.apply_filters(User.all, hash).to_sql
      expected_query = q(
        "SELECT users.* FROM users",
        "WHERE users.admin = 'f' AND users.verified = 't'"
      )

      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/booleans_spec.rb
active_hash_relation-1.4.0 spec/tests/booleans_spec.rb
active_hash_relation-1.2.0 spec/tests/booleans_spec.rb