Sha256: a31352fa20138b957c240c222cd10cbe6a773b1f3e7344a9c7702421335a9b9d

Contents?: true

Size: 900 Bytes

Versions: 3

Compression:

Stored size: 900 Bytes

Contents

require 'acceptance/spec_helper'

describe 'Hiding deleted records from search results', :live => true do
  it "does not return deleted records" do
    pancakes = Article.create! :title => 'Pancakes'
    index

    Article.search('pancakes').should_not be_empty
    pancakes.destroy

    Article.search('pancakes').should be_empty
  end

  it "will catch stale records deleted without callbacks being fired" do
    pancakes = Article.create! :title => 'Pancakes'
    index

    Article.search('pancakes').should_not be_empty
    Article.connection.execute "DELETE FROM articles WHERE id = #{pancakes.id}"

    Article.search('pancakes').should be_empty
  end

  it "removes records from real-time index results" do
    product = Product.create! :name => 'Shiny'

    Product.search('Shiny').to_a.should == [product]

    product.destroy

    Product.search_for_ids('Shiny').should be_empty
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.6 spec/acceptance/remove_deleted_records_spec.rb
thinking-sphinx-3.0.5 spec/acceptance/remove_deleted_records_spec.rb
thinking-sphinx-3.0.4 spec/acceptance/remove_deleted_records_spec.rb