Permalink
Browse files

Don't worry if the document doesn't exist in Sphinx.

  • Loading branch information...
1 parent fb3cb51 commit 15774b85bd2c344cb25a6337477318b39c6066f8 @pat pat committed Sep 5, 2012
View
5 lib/thinking_sphinx/active_record.rb
@@ -274,14 +274,13 @@ def source_of_sphinx_index
end
def delete_in_index(index, document_id)
- return unless ThinkingSphinx.sphinx_running? &&
- search_for_id(document_id, index)
+ return unless ThinkingSphinx.sphinx_running?
ThinkingSphinx::Configuration.instance.client.update(
index, ['sphinx_deleted'], {document_id => [1]}
)
rescue Riddle::ConnectionError, Riddle::ResponseError,
- ThinkingSphinx::SphinxError, Errno::ETIMEDOUT
+ ThinkingSphinx::SphinxError, Errno::ETIMEDOUT, Timeout::Error
# Not the end of the world if Sphinx isn't running.
end
View
6 spec/thinking_sphinx/active_record/delta_spec.rb
@@ -112,12 +112,6 @@
@person.send(:index_delta)
end
- it "shouldn't update the deleted attribute if not in the index" do
- @client.should_not_receive(:update)
-
- @person.send(:index_delta)
- end
-
it "should update the deleted attribute if in the core index" do
Person.stub!(:search_for_id => true)
@client.should_receive(:update)
View
19 spec/thinking_sphinx/active_record_spec.rb
@@ -273,7 +273,6 @@
@configuration.stub!(:client => @client)
Person.sphinx_indexes.each { |index| index.stub!(:delta? => false) }
- Person.stub!(:search_for_id => true)
end
it "should update the core index's deleted flag if in core index" do
@@ -284,19 +283,9 @@
@person.toggle_deleted
end
- it "shouldn't update the core index's deleted flag if the record isn't in it" do
- Person.stub!(:search_for_id => false)
- @client.should_not_receive(:update).with(
- "person_core", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
- )
-
- @person.toggle_deleted
- end
-
it "shouldn't attempt to update the deleted flag if sphinx isn't running" do
ThinkingSphinx.stub!(:sphinx_running? => false)
@client.should_not_receive(:update)
- Person.should_not_receive(:search_for_id)
@person.toggle_deleted
end
@@ -493,14 +482,6 @@
@client = stub('client')
ThinkingSphinx.stub!(:sphinx_running? => true)
ThinkingSphinx::Configuration.instance.stub!(:client => @client)
- Alpha.stub!(:search_for_id => true)
- end
-
- it "should not update if the document isn't in the given index" do
- Alpha.stub!(:search_for_id => false)
- @client.should_not_receive(:update)
-
- Alpha.delete_in_index('alpha_core', 42)
end
it "should direct the update to the supplied index" do

0 comments on commit 15774b8

Please sign in to comment.