Sha256: bfe3aa546856b6cc4fa70307fabb0ccfe6ed62c417bf06f428d5af2ce162c55f

Contents?: true

Size: 795 Bytes

Versions: 12

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

describe PgSearch::Configuration::Column do
  describe "#full_name" do
    with_model :Model do
      table do |t|
        t.string :name
      end
    end

    it "returns the fully-qualified table and column name" do
      column = described_class.new("name", nil, Model)
      expect(column.full_name).to eq(%(#{Model.quoted_table_name}."name"))
    end
  end

  describe "#to_sql" do
    with_model :Model do
      table do |t|
        t.string :name
      end
    end

    it "returns an expression that casts the column to text and coalesces it with an empty string" do
      column = described_class.new("name", nil, Model)
      expect(column.to_sql).to eq(%{coalesce(#{Model.quoted_table_name}."name"::text, '')})
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pg_search-2.3.6 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.3.5 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.3.4 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.3.3 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.3.2 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.3.1 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.3.0 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.2.0 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.7 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.6 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.5 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.4 spec/lib/pg_search/configuration/column_spec.rb