Sha256: 3b6f64cb5bec6b71642abbdc1861d653d8b70cc13d776a64ef3f53a2b69aee14

Contents?: true

Size: 764 Bytes

Versions: 8

Compression:

Stored size: 764 Bytes

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
pg_search-2.1.3 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.2 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.1 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.1.0 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.0.1 spec/lib/pg_search/configuration/column_spec.rb
pg_search-2.0.0 spec/lib/pg_search/configuration/column_spec.rb
pg_search-1.0.6 spec/lib/pg_search/configuration/column_spec.rb
pg_search-1.0.5 spec/lib/pg_search/configuration/column_spec.rb