Merge pull request #3501 from BrokenEagle/fix-2974

Fix erroneous updates to wiki page when nothing changes
This commit is contained in:
Albert Yi
2018-01-15 10:52:36 -08:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@@ -382,7 +382,7 @@ class Artist < ApplicationRecord
if @notes.present?
create_wiki_page(body: @notes, title: name)
end
elsif wiki_page.body != @notes || wiki_page.title != name
elsif (!@notes.nil? && (wiki_page.body != @notes)) || wiki_page.title != name
# if anything changed, we need to update the wiki page
wiki_page.body = @notes unless @notes.nil?
wiki_page.title = name

View File

@@ -190,6 +190,10 @@ class WikiPage < ApplicationRecord
title.tr("_", " ")
end
def wiki_page_changed?
title_changed? || body_changed? || is_locked_changed? || is_deleted_changed? || other_names_changed?
end
def merge_version
prev = versions.last
prev.update_attributes(
@@ -219,7 +223,7 @@ class WikiPage < ApplicationRecord
end
def create_version
if title_changed? || body_changed? || is_locked_changed? || is_deleted_changed? || other_names_changed?
if wiki_page_changed?
if merge_version?
merge_version
else
@@ -235,9 +239,11 @@ class WikiPage < ApplicationRecord
def initialize_creator
self.creator_id = CurrentUser.user.id
end
def initialize_updater
self.updater_id = CurrentUser.user.id
if wiki_page_changed?
self.updater_id = CurrentUser.user.id
end
end
def post_set