Sha256: 160aa83c095007a947ba7be6b95bb4cbfa16bdb305185c87691ecaad1295fbdd

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

require 'spec/spec_helper'

describe ThinkingSphinx::Deltas::FlagAsDeletedJob do
  describe '#perform' do
    before :each do
      ThinkingSphinx.updates_enabled = true
      @client = stub('client', :update => true)
      
      ThinkingSphinx::Configuration.instance.stub!(:client => @client)
      ThinkingSphinx::Search.stub!(:search_for_id => true)
      ThinkingSphinx.stub!(:sphinx_running? => true)
      
      @job = ThinkingSphinx::Deltas::FlagAsDeletedJob.new('foo_core', 12)
    end
    
    it "should not update if Sphinx isn't running" do
      ThinkingSphinx.stub!(:sphinx_running? => false)
      @client.should_not_receive(:update)
      
      @job.perform
    end
    
    it "should not update if the document isn't in the index" do
      ThinkingSphinx::Search.stub!(:search_for_id => false)
      @client.should_not_receive(:update)
      
      @job.perform
    end
    
    it "should update the specified index" do
      @client.should_receive(:update) do |index, attributes, values|
        index.should == 'foo_core'
      end
      
      @job.perform
    end
    
    it "should update the sphinx_deleted attribute" do
      @client.should_receive(:update) do |index, attributes, values|
        attributes.should == ['sphinx_deleted']
      end
      
      @job.perform
    end
    
    it "should set sphinx_deleted for the given document to true" do
      @client.should_receive(:update) do |index, attributes, values|
        values[12].should == [1]
      end
      
      @job.perform
    end
    
    it "should check for the existence of the document in the specified index" do
      ThinkingSphinx::Search.should_receive(:search_for_id) do |id, index|
        index.should == 'foo_core'
      end
      
      @job.perform
    end
    
    it "should check for the existence of the given document id" do
      ThinkingSphinx::Search.should_receive(:search_for_id) do |id, index|
        id.should == 12
      end
      
      @job.perform
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ts-delayed-delta-1.0.0 spec/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job_spec.rb