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

This commit is contained in:
Mark VanLandingham 2020-04-20 14:51:49 -05:00 committed by GitHub
parent 25bed4f643
commit 06796bec8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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