Sha256: 0a3ac823ff72326ded5ac156c789754d3681f34ffbf259d3e6225b14b404ff2e
Contents?: true
Size: 1.64 KB
Versions: 9
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe ThinkingSphinx::Deletion do describe '.perform' do let(:connection) { double('connection', :execute => nil) } let(:index) { double('index', :name => 'foo_core', :type => 'plain', :distributed? => false) } before :each do allow(ThinkingSphinx::Connection).to receive(:take).and_yield(connection) allow(Riddle::Query).to receive_messages :update => 'UPDATE STATEMENT' end context 'index is SQL-backed' do it "updates the deleted flag to false" do expect(connection).to receive(:execute).with( 'UPDATE foo_core SET sphinx_deleted = 1 WHERE sphinx_internal_id IN (7)' ) ThinkingSphinx::Deletion.perform index, 7 end it "doesn't care about Sphinx errors" do allow(connection).to receive(:execute). and_raise(ThinkingSphinx::ConnectionError.new('')) expect { ThinkingSphinx::Deletion.perform index, 7 }.not_to raise_error end end context "index is real-time" do before :each do allow(index).to receive_messages :type => 'rt' end it "deletes the record to false" do expect(connection).to receive(:execute). with('DELETE FROM foo_core WHERE sphinx_internal_id IN (7)') ThinkingSphinx::Deletion.perform index, 7 end it "doesn't care about Sphinx errors" do allow(connection).to receive(:execute). and_raise(ThinkingSphinx::ConnectionError.new('')) expect { ThinkingSphinx::Deletion.perform index, 7 }.not_to raise_error end end end end
Version data entries
9 entries across 9 versions & 1 rubygems