Merge pull request #3381 from evazion/fix-3323
Fix #3323: Exclude post replacements from Mod Actions
This commit is contained in:
@@ -56,7 +56,6 @@ class PostReplacement < ApplicationRecord
|
||||
|
||||
if md5_changed
|
||||
post.comments.create!({creator: User.system, body: comment_replacement_message, do_not_bump_post: true}, without_protection: true)
|
||||
ModAction.log(modaction_replacement_message)
|
||||
else
|
||||
post.queue_backup
|
||||
end
|
||||
@@ -123,10 +122,6 @@ class PostReplacement < ApplicationRecord
|
||||
%("#{creator.name}":[/users/#{creator.id}] replaced this post with a new image:\n\n#{replacement_message})
|
||||
end
|
||||
|
||||
def modaction_replacement_message
|
||||
"replaced post ##{post.id}:\n\n#{replacement_message}"
|
||||
end
|
||||
|
||||
def replacement_message
|
||||
linked_source = linked_source(replacement_url)
|
||||
linked_source_was = linked_source(post.source_was)
|
||||
|
||||
@@ -46,7 +46,6 @@ class PostReplacementTest < ActiveSupport::TestCase
|
||||
@post.update(source: "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png")
|
||||
@post.replace!(replacement_url: "https://www.google.com/intl/en_ALL/images/logo.gif", tags: "-tag1 tag2")
|
||||
@upload = Upload.last
|
||||
@mod_action = ModAction.last
|
||||
end
|
||||
|
||||
context "that is then undone" do
|
||||
@@ -95,10 +94,6 @@ class PostReplacementTest < ActiveSupport::TestCase
|
||||
assert_equal(false, @post.is_pending)
|
||||
end
|
||||
|
||||
should "log a mod action" do
|
||||
assert_match(/replaced post ##{@post.id}/, @mod_action.description)
|
||||
end
|
||||
|
||||
should "leave a system comment" do
|
||||
comment = @post.comments.last
|
||||
|
||||
@@ -246,7 +241,7 @@ class PostReplacementTest < ActiveSupport::TestCase
|
||||
context "a post when replaced with a HTML source" do
|
||||
should "record the image URL as the replacement URL, not the HTML source" do
|
||||
replacement_url = "https://twitter.com/nounproject/status/540944400767922176"
|
||||
image_url = "http://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:orig"
|
||||
image_url = "https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:orig"
|
||||
@post.replace!(replacement_url: replacement_url)
|
||||
|
||||
assert_equal(image_url, @post.replacements.last.replacement_url)
|
||||
@@ -264,7 +259,7 @@ class PostReplacementTest < ActiveSupport::TestCase
|
||||
|
||||
should "not queue a deletion or log a comment" do
|
||||
upload_file("#{Rails.root}/test/files/test.jpg", "test.jpg") do |file|
|
||||
assert_no_difference(["@post.comments.count", "ModAction.count"]) do
|
||||
assert_no_difference(["@post.comments.count"]) do
|
||||
@post.replace!(replacement_file: file, replacement_url: "")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user