mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 10:24:39 +08:00
DEV: Add specs for hashtags related code (#18526)
Adding a couple of small specs to code around hashtags for tags and categories since I will be working in this area soon and these were not covered.
This commit is contained in:
@ -15,4 +15,35 @@ RSpec.describe PrettyText::Helpers do
|
||||
expect(result[short_url][:url]).to eq("https://awesome.com#{upload.url}")
|
||||
end
|
||||
end
|
||||
|
||||
describe ".category_tag_hashtag_lookup" do
|
||||
fab!(:tag) { Fabricate(:tag, name: "somecooltag") }
|
||||
fab!(:category) do
|
||||
Fabricate(:category, name: "Some Awesome Category", slug: "someawesomecategory")
|
||||
end
|
||||
|
||||
it "handles tags based on slug with TAG_HASHTAG_POSTFIX" do
|
||||
expect(
|
||||
PrettyText::Helpers.category_tag_hashtag_lookup(
|
||||
+"somecooltag#{PrettyText::Helpers::TAG_HASHTAG_POSTFIX}",
|
||||
),
|
||||
).to eq([tag.url, "somecooltag"])
|
||||
end
|
||||
|
||||
it "handles categories based on slug" do
|
||||
expect(PrettyText::Helpers.category_tag_hashtag_lookup("someawesomecategory")).to eq(
|
||||
[category.url, "someawesomecategory"],
|
||||
)
|
||||
end
|
||||
|
||||
it "handles tags based on slug without TAG_HASHTAG_POSTFIX" do
|
||||
expect(PrettyText::Helpers.category_tag_hashtag_lookup(+"somecooltag")).to eq(
|
||||
[tag.url, "somecooltag"],
|
||||
)
|
||||
end
|
||||
|
||||
it "returns nil when no tag or category that matches exists" do
|
||||
expect(PrettyText::Helpers.category_tag_hashtag_lookup("blah")).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user