Sha256: 45e5ed4bbb95e495be08f8346a893d6b2aeedf5ff4b6ad9e702c7e0e47b7ad6d

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe PgSearch::Configuration::ForeignColumn do
  describe "#alias" do
    with_model :AssociatedModel do
      table do |t|
        t.string "title"
      end
    end

    with_model :Model do
      table do |t|
        t.string "title"
        t.belongs_to :another_model, index: false
      end

      model do
        include PgSearch::Model
        belongs_to :another_model, class_name: 'AssociatedModel'

        pg_search_scope :with_another, associated_against: { another_model: :title }
      end
    end

    it "returns a consistent string" do
      association = PgSearch::Configuration::Association.new(Model,
                                                             :another_model,
                                                             :title)
      foreign_column = described_class.new("title", nil, Model, association)

      column_alias = foreign_column.alias
      expect(column_alias).to be_a String
      expect(foreign_column.alias).to eq column_alias
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pg_search-2.3.6 spec/lib/pg_search/configuration/foreign_column_spec.rb
pg_search-2.3.5 spec/lib/pg_search/configuration/foreign_column_spec.rb
pg_search-2.3.4 spec/lib/pg_search/configuration/foreign_column_spec.rb
pg_search-2.3.3 spec/lib/pg_search/configuration/foreign_column_spec.rb
pg_search-2.3.2 spec/lib/pg_search/configuration/foreign_column_spec.rb
pg_search-2.3.1 spec/lib/pg_search/configuration/foreign_column_spec.rb
pg_search-2.3.0 spec/lib/pg_search/configuration/foreign_column_spec.rb