mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Permalinks for tags
This commit is contained in:
@@ -32,6 +32,7 @@ describe Permalink do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let(:post) { Fabricate(:post, topic: topic) }
|
||||
let(:category) { Fabricate(:category) }
|
||||
let(:tag) { Fabricate(:tag) }
|
||||
subject(:target_url) { permalink.target_url }
|
||||
|
||||
it "returns a topic url when topic_id is set" do
|
||||
@@ -77,6 +78,24 @@ describe Permalink do
|
||||
expect(target_url).to eq(post.url)
|
||||
end
|
||||
|
||||
it "returns a tag url when tag_id is set" do
|
||||
permalink.tag_id = tag.id
|
||||
expect(target_url).to eq(tag.full_url)
|
||||
end
|
||||
|
||||
it "returns nil when tag_id is set but tag is not found" do
|
||||
permalink.tag_id = 99999
|
||||
expect(target_url).to eq(nil)
|
||||
end
|
||||
|
||||
it "returns a post url when topic_id, post_id, category_id and tag_id are all set for some reason" do
|
||||
permalink.post_id = post.id
|
||||
permalink.topic_id = topic.id
|
||||
permalink.category_id = category.id
|
||||
permalink.tag_id = tag.id
|
||||
expect(target_url).to eq(post.url)
|
||||
end
|
||||
|
||||
it "returns nil when nothing is set" do
|
||||
expect(target_url).to eq(nil)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user