From be338892ecff3925050c77b2a3b8bbdf69ef4739 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 15 Jun 2016 14:15:30 -0400 Subject: [PATCH] FIX: post revision history wasn't showing tags correctly --- app/serializers/post_revision_serializer.rb | 12 ++++++++---- lib/post_revisor.rb | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/serializers/post_revision_serializer.rb b/app/serializers/post_revision_serializer.rb index d1c935411..4df9012e8 100644 --- a/app/serializers/post_revision_serializer.rb +++ b/app/serializers/post_revision_serializer.rb @@ -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( diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb index 406f1fc5c..f9e68cf56 100644 --- a/lib/post_revisor.rb +++ b/lib/post_revisor.rb @@ -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