From feb3ec07500586e0e9d3dc5594414f3b59766349 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 2 Dec 2017 19:10:38 -0600 Subject: [PATCH] Fix #3417: Deleting a user's comment credits the change to them. --- app/models/comment.rb | 4 ++-- test/unit/comment_test.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index be656fc88..3ca0a40bb 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index fa8df48d7..e14da6afc 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -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