FIX: post revision history wasn't showing tags correctly

This commit is contained in:
Neil Lalonde 2016-06-15 14:15:30 -04:00
parent 17b1179103
commit be338892ec
2 changed files with 9 additions and 5 deletions

View File

@ -22,7 +22,8 @@ class PostRevisionSerializer < ApplicationSerializer
:edit_reason,
:body_changes,
:title_changes,
:user_changes
:user_changes,
:tags_changes
# Creates a field called field_name_changes with previous and
@ -41,7 +42,6 @@ class PostRevisionSerializer < ApplicationSerializer
end
add_compared_field :wiki
add_compared_field :tags
def previous_hidden
previous["hidden"]
@ -150,8 +150,12 @@ class PostRevisionSerializer < ApplicationSerializer
}
end
def tags_changes
{ previous: previous["tags"], current: current["tags"] }
end
def include_tags_changes?
SiteSetting.tagging_enabled
SiteSetting.tagging_enabled && previous["tags"] != current["tags"]
end
protected
@ -190,7 +194,7 @@ class PostRevisionSerializer < ApplicationSerializer
end
if SiteSetting.tagging_enabled
latest_modifications["tags"] = post.topic.tags.map(&:name)
latest_modifications["tags"] = [post.topic.tags.map(&:name)]
end
post_revisions << PostRevision.new(

View File

@ -80,7 +80,7 @@ class PostRevisor
tc.check_result(false)
next
end
tc.record_change('tags', prev_tags, tags)
tc.record_change('tags', prev_tags, tags) unless prev_tags.sort == tags.sort
end
end