Skip to content

A platform for community discussion. Free, open, simple.

FIX: 'only_hidden_tags_changed?' method returned 'true' even when tags are not changed.

Vinoth Kannan5e55e75aedf8
diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb
index 02b88d11738..cd68bf7bb09 100644
--- a/lib/post_revisor.rb
+++ b/lib/post_revisor.rb
@@ -522,14 +522,17 @@ class PostRevisor
end
def only_hidden_tags_changed?
+ return false if (hidden_tag_names = DiscourseTagging.hidden_tag_names).blank?
+
modifications = post_changes.merge(@topic_changes.diff)
- if modifications.keys.size == 1 && tags_diff = modifications["tags"]
+ if modifications.keys.size == 1 && (tags_diff = modifications["tags"]).present?
a, b = tags_diff[0] || [], tags_diff[1] || []
changed_tags = ((a + b) - (a & b)).map(&:presence).compact
- if (changed_tags - DiscourseTagging.hidden_tag_names(nil)).empty?
+ if (changed_tags - hidden_tag_names).empty?
return true
end
end
+
false
end
diff --git a/spec/components/post_revisor_spec.rb b/spec/components/post_revisor_spec.rb
index a47596fe38f..598fb686d5d 100644
--- a/spec/components/post_revisor_spec.rb
+++ b/spec/components/post_revisor_spec.rb
@@ -190,6 +190,12 @@ describe PostRevisor do
expect(post.public_version).to eq(1)
expect(post.revisions.size).to eq(0)
end
+
+ it "should bump the topic" do
+ expect {
+ subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds)
+ }.to change { post.topic.bumped_at }
+ end
end
describe 'revision much later' do
@@ -783,6 +789,13 @@ describe PostRevisor do
}.to_not change { topic.reload.bumped_at }
end
+ it "should bump topic if non staff-only tags are added" do
+ expect {
+ result = subject.revise!(Fabricate(:admin), raw: post.raw, tags: topic.tags.map(&:name) + [Fabricate(:tag).name])
+ expect(result).to eq(true)
+ }.to change { topic.reload.bumped_at }
+ end
+
it "creates a hidden revision" do
subject.revise!(Fabricate(:admin), raw: post.raw, tags: topic.tags.map(&:name) + ['secret'])
expect(post.reload.revisions.first.hidden).to eq(true)