Sha256: e5b880234c07e09fd25fc1cf71c98a8526678299279495d1d9ec43607687ac9a

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'acceptance/spec_helper'

describe 'SQL delta indexing', :live => true do
  it "automatically indexes new records" do
    guards = Book.create(
      :title => 'Guards! Guards!', :author => 'Terry Pratchett'
    )
    index

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

    men = Book.create(
      :title => 'Men At Arms', :author => 'Terry Pratchett'
    )
    work
    sleep 0.25

    Book.search('Terry Pratchett').to_a.should == [guards, men]
  end

  it "automatically indexes updated records" do
    book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
    index

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

    book.reload.update_attributes(:author => 'Terry Pratchett')
    work
    sleep 0.25

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

  it "does not match on old values" do
    book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
    index

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

    book.reload.update_attributes(:author => 'Terry Pratchett')
    work
    sleep 0.25

    Book.search('Harry').should be_empty
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ts-delayed-delta-2.1.0 spec/acceptance/delayed_job_deltas_spec.rb
ts-delayed-delta-2.0.2 spec/acceptance/delayed_job_deltas_spec.rb
ts-delayed-delta-2.0.1 spec/acceptance/delayed_job_deltas_spec.rb
ts-delayed-delta-2.0.0 spec/acceptance/delayed_job_deltas_spec.rb