FIX: Set category description to first posts cooked value (#9478)
This commit is contained in:
parent
25bed4f643
commit
06796bec8b
|
@ -287,6 +287,7 @@ class Category < ActiveRecord::Base
|
||||||
update_column(:topic_id, t.id)
|
update_column(:topic_id, t.id)
|
||||||
post = t.posts.build(raw: description || post_template, user: user)
|
post = t.posts.build(raw: description || post_template, user: user)
|
||||||
post.save!(validate: false)
|
post.save!(validate: false)
|
||||||
|
update_column(:description, post.cooked) if description.present?
|
||||||
|
|
||||||
t
|
t
|
||||||
end
|
end
|
||||||
|
|
|
@ -403,6 +403,16 @@ describe Category do
|
||||||
expect(@category.topics_year).to eq(0)
|
expect(@category.topics_year).to eq(0)
|
||||||
end
|
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
|
it "renames the definition when renamed" do
|
||||||
@category.update(name: 'Troutfishing')
|
@category.update(name: 'Troutfishing')
|
||||||
@topic.reload
|
@topic.reload
|
||||||
|
|
Loading…
Reference in New Issue