FIX: cannot remove tags from a topic
This commit is contained in:
parent
5a03eca74a
commit
5047979f96
|
@ -84,6 +84,17 @@ class PostRevisor
|
|||
end
|
||||
end
|
||||
|
||||
track_topic_field(:tags_empty_array) do |tc, val|
|
||||
if val.present? && tc.guardian.can_tag_topics?
|
||||
prev_tags = tc.topic.tags.map(&:name)
|
||||
if !DiscourseTagging.tag_topic_by_names(tc.topic, tc.guardian, [])
|
||||
tc.check_result(false)
|
||||
next
|
||||
end
|
||||
tc.record_change('tags', prev_tags, nil)
|
||||
end
|
||||
end
|
||||
|
||||
# AVAILABLE OPTIONS:
|
||||
# - revised_at: changes the date of the revision
|
||||
# - force_new_version: bypass ninja-edit window
|
||||
|
|
|
@ -415,6 +415,14 @@ describe PostRevisor do
|
|||
expect(post.topic.tags.size).to eq(0)
|
||||
end
|
||||
|
||||
it "can remove all tags using tags_empty_array" do
|
||||
topic.tags = [Fabricate(:tag, name: "stuff")]
|
||||
result = subject.revise!(Fabricate(:user), { raw: "lets totally update the body", tags_empty_array: "true" })
|
||||
expect(result).to eq(true)
|
||||
post.reload
|
||||
expect(post.topic.tags.size).to eq(0)
|
||||
end
|
||||
|
||||
it "can't add staff-only tags" do
|
||||
SiteSetting.staff_tags = "important"
|
||||
result = subject.revise!(Fabricate(:user), { raw: "lets totally update the body", tags: ['important', 'stuff'] })
|
||||
|
|
Loading…
Reference in New Issue