A platform for community discussion. Free, open, simple.
FIX: Allow clearing tag descriptions in legacy tag update endpoint (#38405)
Natalie Tay36ac0f8ead15
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rbindex 3c499f8a7e0..b3818de2872 100644--- a/app/controllers/tags_controller.rb+++ b/app/controllers/tags_controller.rb@@ -288,7 +288,7 @@ class TagsController < ::ApplicationControllerprevious_tag_name = @tag.name@tag.name = DiscourseTagging.clean_tag(new_tag_name) if new_tag_name.present?- @tag.description = new_tag_description if new_tag_description.present?+ @tag.description = new_tag_description if new_tag.has_key?(:description)if @tag.saveif @tag.name != previous_tag_namediff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rbindex f0434a2fe56..8679fbfcef2 100644--- a/spec/requests/tags_controller_spec.rb+++ b/spec/requests/tags_controller_spec.rb@@ -960,6 +960,15 @@ RSpec.describe TagsController doexpect(tag.reload.description).to eq("New description")end+ it "can clear the tag description" do+ tag.update!(description: "existing description")++ put "/tag/#{tag.name}.json", params: { tag: { description: "" } }++ expect(response.status).to eq(200)+ expect(tag.reload.description).to be_blank+ end+it "returns 403 for non-admins" dosign_in(regular_user)put "/tag/#{tag.name}.json", params: { tag: { description: "New description" } }