Sha256: c6113301c295bf2b9e0b51baa1273c717e19f819507ef0899e9d3e28eb98bc26

Contents?: true

Size: 888 Bytes

Versions: 10

Compression:

Stored size: 888 Bytes

Contents

require 'acceptance/spec_helper'

describe 'Scoping association search calls by foreign keys', :live => true do
  it "limits results to those matching the foreign key" do
    pat       = User.create :name => 'Pat'
    melbourne = Article.create :title => 'Guide to Melbourne', :user => pat
    paul      = User.create :name => 'Paul'
    dublin    = Article.create :title => 'Guide to Dublin',    :user => paul
    index

    pat.articles.search('Guide').to_a.should == [melbourne]
  end

  it "limits id-only results to those matching the foreign key" do
    pat       = User.create :name => 'Pat'
    melbourne = Article.create :title => 'Guide to Melbourne', :user => pat
    paul      = User.create :name => 'Paul'
    dublin    = Article.create :title => 'Guide to Dublin',    :user => paul
    index

    pat.articles.search_for_ids('Guide').to_a.should == [melbourne.id]
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.0 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.6 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.5 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.4 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.3 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.2 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.1 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.0 spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.0.rc spec/acceptance/association_scoping_spec.rb
thinking-sphinx-3.0.0.pre spec/acceptance/association_scoping_spec.rb