From b651605d6e4fb5df49a89f7a5a3afdb5190160bd Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 14 Feb 2019 10:12:40 +0530 Subject: [PATCH] FIX: tags added while editing a pending approval topic do not show up (#6959) --- app/models/queued_post.rb | 6 ++++++ spec/models/queued_post_spec.rb | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/app/models/queued_post.rb b/app/models/queued_post.rb index 92cc688fa96..247db155a1c 100644 --- a/app/models/queued_post.rb +++ b/app/models/queued_post.rb @@ -91,6 +91,12 @@ class QueuedPost < ActiveRecord::Base end end + if create_options[:tags].present? && + created_post.post_number == 1 && + created_post.topic.tags.blank? + DiscourseTagging.tag_topic_by_names(created_post.topic, Guardian.new(approved_by), create_options[:tags]) + end + # Do sidekiq work outside of the transaction creator.enqueue_jobs creator.trigger_after_events diff --git a/spec/models/queued_post_spec.rb b/spec/models/queued_post_spec.rb index 23c7dd8bdf6..90aa85a1ba4 100644 --- a/spec/models/queued_post_spec.rb +++ b/spec/models/queued_post_spec.rb @@ -110,6 +110,7 @@ describe QueuedPost do title: 'This is the topic title to queue up', archetype: 'regular', category: category.id, + tags: ['evil', 'trout'], meta_data: { evil: 'trout' } }) } @@ -122,6 +123,8 @@ describe QueuedPost do end it "creates the post and topic" do + SiteSetting.tagging_enabled = true + SiteSetting.min_trust_level_to_tag_topics = 4 topic_count, post_count = Topic.count, Post.count post = qp.approve!(admin) @@ -134,6 +137,7 @@ describe QueuedPost do topic = post.topic expect(topic).to be_present expect(topic.category).to eq(category) + expect(topic.tags.map(&:name)).to contain_exactly('evil', 'trout') expect(UserHistory.where(action: UserHistory.actions[:post_approved]).count).to eq(1) end