Merge pull request #2774 from evazion/fix-2771
Fix #2771: Approving deleted image doesn't create mod action.
This commit is contained in:
@@ -327,6 +327,10 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
PostApproval.create(user_id: CurrentUser.id, post_id: id)
|
PostApproval.create(user_id: CurrentUser.id, post_id: id)
|
||||||
|
|
||||||
|
if is_deleted_was == true
|
||||||
|
ModAction.create(:description => "undeleted post ##{id}")
|
||||||
|
end
|
||||||
|
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -329,10 +329,30 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be undeleted" do
|
context "when undeleted" do
|
||||||
@post.undelete!
|
should "be undeleted" do
|
||||||
@post.reload
|
@post.undelete!
|
||||||
assert_equal(false, @post.is_deleted?)
|
assert_equal(false, @post.reload.is_deleted?)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a mod action" do
|
||||||
|
assert_difference("ModAction.count", 1) do
|
||||||
|
@post.undelete!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when approved" do
|
||||||
|
should "be undeleted" do
|
||||||
|
@post.approve!
|
||||||
|
assert_equal(false, @post.reload.is_deleted?)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a mod action" do
|
||||||
|
assert_difference("ModAction.count", 1) do
|
||||||
|
@post.approve!
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be appealed" do
|
should "be appealed" do
|
||||||
|
|||||||
Reference in New Issue
Block a user