A platform for community discussion. Free, open, simple.
FIX: Set category description to first posts cooked value (#9478)
Mark VanLandingham06796bec8be1
diff --git a/app/models/category.rb b/app/models/category.rbindex 44d115cad0a..c19d3848cc1 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -287,6 +287,7 @@ class Category < ActiveRecord::Baseupdate_column(:topic_id, t.id)post = t.posts.build(raw: description || post_template, user: user)post.save!(validate: false)+ update_column(:description, post.cooked) if description.present?tenddiff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rbindex b2da4115047..7b550a9c1d3 100644--- a/spec/models/category_spec.rb+++ b/spec/models/category_spec.rb@@ -403,6 +403,16 @@ describe Category doexpect(@category.topics_year).to eq(0)end+ it "cooks the definition" do+ category = Category.create(+ name: 'little-test',+ user_id: Discourse.system_user.id,+ description: "click the link [here](https://fakeurl.com)"+ )+ expect(category.description.include?("[here]")).to eq(false)+ expect(category.description).to eq(category.topic.first_post.cooked)+ end+it "renames the definition when renamed" do@category.update(name: 'Troutfishing')@topic.reload