Sha256: 25aab07f93542d973455e0dd0cd8fb3af71fd11249e34041cb8bb2fcc37967ed

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

require 'acceptance/spec_helper'

describe 'Suspend deltas for a given action', :live => true do
  it "does not update the delta indices until after the block is finished" do
    book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
    index

    Book.search('Harry').to_a.should == [book]

    ThinkingSphinx::Deltas.suspend :book do
      book.reload.update_attributes(:author => 'Terry Pratchett')
      sleep 0.25

      Book.search('Terry').to_a.should == []
    end

    sleep 0.25
    Book.search('Terry').to_a.should == [book]
  end

  it "returns core records even though they are no longer valid" do
    book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
    index

    Book.search('Harry').to_a.should == [book]

    ThinkingSphinx::Deltas.suspend :book do
      book.reload.update_attributes(:author => 'Terry Pratchett')
      sleep 0.25

      Book.search('Terry').to_a.should == []
    end

    sleep 0.25
    Book.search('Harry').to_a.should == [book]
  end

  it "marks core records as deleted" do
    book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
    index

    Book.search('Harry').to_a.should == [book]

    ThinkingSphinx::Deltas.suspend_and_update :book do
      book.reload.update_attributes(:author => 'Terry Pratchett')
      sleep 0.25

      Book.search('Terry').to_a.should == []
    end

    sleep 0.25
    Book.search('Harry').to_a.should be_empty
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
thinking-sphinx-3.2.0 spec/acceptance/suspended_deltas_spec.rb
thinking-sphinx-3.1.4 spec/acceptance/suspended_deltas_spec.rb
thinking-sphinx-3.1.3 spec/acceptance/suspended_deltas_spec.rb
thinking-sphinx-3.1.2 spec/acceptance/suspended_deltas_spec.rb
thinking-sphinx-3.1.1 spec/acceptance/suspended_deltas_spec.rb
thinking-sphinx-3.1.0 spec/acceptance/suspended_deltas_spec.rb