Sha256: 9713133040c30c90b465232af8ca7ae2b0ce9eb3f4e80f558a5d531f31ed8de6

Contents?: true

Size: 1.1 KB

Versions: 16

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'acceptance/spec_helper'

describe 'Searching across models', :live => true do
  it "returns results" do
    article = Article.create! :title => 'Pancakes'
    index

    expect(ThinkingSphinx.search.first).to eq(article)
  end

  it "returns results matching the given query" do
    pancakes = Article.create! :title => 'Pancakes'
    waffles  = Article.create! :title => 'Waffles'
    index

    articles = ThinkingSphinx.search 'pancakes'
    expect(articles).to include(pancakes)
    expect(articles).not_to include(waffles)
  end

  it "handles results from different models" do
    article = Article.create! :title => 'Pancakes'
    book    = Book.create! :title => 'American Gods'
    index

    expect(ThinkingSphinx.search.to_a).to match_array([article, book])
  end

  it "filters by multiple classes" do
    article = Article.create! :title => 'Pancakes'
    book    = Book.create! :title => 'American Gods'
    user    = User.create! :name => 'Pat'
    index

    expect(ThinkingSphinx.search(:classes => [User, Article]).to_a).
      to match_array([article, user])
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
thinking-sphinx-5.5.1 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.5.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.4.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.3.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.2.1 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.2.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.1.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-5.0.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.4.1 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.4.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.3.2 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.3.1 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.3.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.2.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.1.0 spec/acceptance/searching_across_models_spec.rb
thinking-sphinx-4.0.0 spec/acceptance/searching_across_models_spec.rb