Sha256: 12003a5d4752634c86533526aca9de9dd7511673284c9d489245b0927de595c0

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 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

    expect(Book.search('Terry Pratchett').to_a).to  eq([guards])

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

    expect(Book.search('Terry Pratchett').to_a).to eq([guards, men])
  end

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

    expect(Book.search('Harry').to_a).to  eq([book])

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

    expect(Book.search('Terry').to_a).to  eq([book])
  end

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

    expect(Book.search('Harry').to_a).to  eq([book])

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

    expect(Book.search('Harry')).to be_empty
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ts-resque-delta-2.1.0 spec/acceptance/resque_deltas_spec.rb