Fix #3417: Deleting a user's comment credits the change to them.

This commit is contained in:
evazion
2017-12-02 19:10:38 -06:00
parent 2000719227
commit feb3ec0750
2 changed files with 7 additions and 2 deletions

View File

@@ -182,8 +182,8 @@ class Comment < ApplicationRecord
end
def initialize_updater
self.updater_id ||= CurrentUser.user.id
self.updater_ip_addr ||= CurrentUser.ip_addr
self.updater_id = CurrentUser.user.id
self.updater_ip_addr = CurrentUser.ip_addr
end
def creator_name

View File

@@ -244,6 +244,11 @@ class CommentTest < ActiveSupport::TestCase
@comment.update_attributes({:body => "nope"}, :as => :moderator)
end
end
should "credit the moderator as the updater" do
@comment.update({ body: "test" }, as: :moderator)
assert_equal(@mod.id, @comment.updater_id)
end
end
context "that is below the score threshold" do