mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FIX: Cook hashtags in small action posts (#23008)
There is no decorateCooked equivalent for small action posts, so we need to manually call decorateHashtags when there is a custom message for small action posts in order for the hashtags to get their coloured icon/square.
This commit is contained in:
@ -149,6 +149,49 @@ describe "Using #hashtag autocompletion to search for and lookup categories and
|
||||
end
|
||||
end
|
||||
|
||||
it "decorates post small actions with hashtags in the custom message" do
|
||||
post =
|
||||
Fabricate(:small_action, raw: "this is a #cool-cat category and a #cooltag tag", topic: topic)
|
||||
topic_page.visit_topic(topic)
|
||||
expect(topic_page).to have_post_number(post.post_number)
|
||||
expect(find(".small-action-custom-message")["innerHTML"]).to have_tag(
|
||||
"a",
|
||||
with: {
|
||||
class: "hashtag-cooked",
|
||||
href: tag.url,
|
||||
"data-type": "tag",
|
||||
"data-slug": tag.name,
|
||||
"data-id": tag.id,
|
||||
"aria-label": tag.name,
|
||||
},
|
||||
) do
|
||||
with_tag(
|
||||
"svg",
|
||||
with: {
|
||||
class: "fa d-icon d-icon-tag svg-icon hashtag-color--tag-#{tag.id} svg-string",
|
||||
},
|
||||
) { with_tag("use", with: { href: "#tag" }) }
|
||||
end
|
||||
expect(find(".small-action-custom-message")["innerHTML"]).to have_tag(
|
||||
"a",
|
||||
with: {
|
||||
class: "hashtag-cooked",
|
||||
href: category.url,
|
||||
"data-type": "category",
|
||||
"data-slug": category.slug,
|
||||
"data-id": category.id,
|
||||
"aria-label": category.name,
|
||||
},
|
||||
) do
|
||||
with_tag(
|
||||
"span",
|
||||
with: {
|
||||
class: "hashtag-category-badge hashtag-color--category-#{category.id}",
|
||||
},
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when a user cannot access the category for a hashtag cooked in another post" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:manager_group) { Fabricate(:group, name: "Managers") }
|
||||
|
Reference in New Issue
Block a user