posts: fix expunging posts not removing image from iqdb.
`File.exists?(preview_file_path)` is always false because the file has already been deleted by this point. Remove the check entirely.
This commit is contained in:
@@ -1713,9 +1713,7 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remove_iqdb_async
|
def remove_iqdb_async
|
||||||
if File.exists?(preview_file_path) && Post.iqdb_enabled?
|
Post.remove_iqdb(id)
|
||||||
Post.iqdb_sqs_service.send_message("remove\n#{id}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_iqdb
|
def update_iqdb
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ module IqdbTestHelper
|
|||||||
|
|
||||||
service = mock_sqs_service.new
|
service = mock_sqs_service.new
|
||||||
Post.stubs(:iqdb_sqs_service).returns(service)
|
Post.stubs(:iqdb_sqs_service).returns(service)
|
||||||
|
Post.stubs(:iqdb_enabled?).returns(true)
|
||||||
|
|
||||||
Danbooru.config.stubs(:iqdbs_auth_key).returns("hunter2")
|
Danbooru.config.stubs(:iqdbs_auth_key).returns("hunter2")
|
||||||
Danbooru.config.stubs(:iqdbs_server).returns("http://localhost:3004")
|
Danbooru.config.stubs(:iqdbs_server).returns("http://localhost:3004")
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
assert_equal(false, File.exists?(@post.file_path))
|
assert_equal(false, File.exists?(@post.file_path))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "remove the post from iqdb" do
|
||||||
|
mock_iqdb_service!
|
||||||
|
Post.iqdb_sqs_service.expects(:send_message).with("remove\n#{@post.id}")
|
||||||
|
|
||||||
|
TestAfterCommit.with_commits(true) do
|
||||||
|
@post.expunge!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "that is status locked" do
|
context "that is status locked" do
|
||||||
setup do
|
setup do
|
||||||
@post.update_attributes({:is_status_locked => true}, :as => :admin)
|
@post.update_attributes({:is_status_locked => true}, :as => :admin)
|
||||||
|
|||||||
Reference in New Issue
Block a user