FIX: Set category description to first posts cooked value (#9478)

FIX: Set category description to first posts cooked value (#9478)

diff --git a/app/models/category.rb b/app/models/category.rb
index 44d115c..c19d384 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -287,6 +287,7 @@ class Category < ActiveRecord::Base
       update_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?
 
       t
     end
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index b2da411..7b550a9 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -403,6 +403,16 @@ describe Category do
       expect(@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

GitHub sha: 06796bec

This commit appears in #9478 which was approved by eviltrout. It was merged by markvanlan.