mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Include entire slug path in permalinks
This is a temporary fix since these URLs should contain the id as well.
This commit is contained in:
@@ -661,36 +661,68 @@ describe Category do
|
||||
end
|
||||
|
||||
describe "#url" do
|
||||
it "builds a url for normal categories" do
|
||||
category = Fabricate(:category_with_definition, name: "cats")
|
||||
expect(category.url).to eq "/c/cats"
|
||||
before_all do
|
||||
SiteSetting.max_category_nesting = 3
|
||||
end
|
||||
|
||||
fab!(:category) { Fabricate(:category, name: "root") }
|
||||
|
||||
fab!(:sub_category) do
|
||||
Fabricate(
|
||||
:category,
|
||||
name: "child",
|
||||
parent_category_id: category.id,
|
||||
)
|
||||
end
|
||||
|
||||
fab!(:sub_sub_category) do
|
||||
Fabricate(
|
||||
:category,
|
||||
name: "child_of_child",
|
||||
parent_category_id: sub_category.id,
|
||||
)
|
||||
end
|
||||
|
||||
describe "for normal categories" do
|
||||
it "builds a url" do
|
||||
expect(category.url).to eq("/c/root")
|
||||
end
|
||||
end
|
||||
|
||||
describe "for subcategories" do
|
||||
it "includes the parent category" do
|
||||
parent_category = Fabricate(:category_with_definition, name: "parent")
|
||||
it "builds a url" do
|
||||
expect(sub_category.url).to eq("/c/root/child")
|
||||
end
|
||||
end
|
||||
|
||||
subcategory =
|
||||
Fabricate(
|
||||
:category_with_definition,
|
||||
name: "child",
|
||||
parent_category_id: parent_category.id
|
||||
)
|
||||
|
||||
expect(subcategory.url).to eq "/c/parent/child"
|
||||
describe "for sub-sub-categories" do
|
||||
it "builds a url" do
|
||||
expect(sub_sub_category.url)
|
||||
.to eq("/c/root/child/child-of-child")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#url_with_id" do
|
||||
fab!(:category) { Fabricate(:category_with_definition, name: 'cats') }
|
||||
fab!(:category) do
|
||||
Fabricate(
|
||||
:category_with_definition,
|
||||
name: 'cats',
|
||||
)
|
||||
end
|
||||
|
||||
it "includes the id in the URL" do
|
||||
expect(category.url_with_id).to eq("/c/cats/#{category.id}")
|
||||
end
|
||||
|
||||
context "child category" do
|
||||
fab!(:child_category) { Fabricate(:category_with_definition, parent_category_id: category.id, name: 'dogs') }
|
||||
fab!(:child_category) do
|
||||
Fabricate(
|
||||
:category,
|
||||
parent_category_id: category.id,
|
||||
name: 'dogs',
|
||||
)
|
||||
end
|
||||
|
||||
it "includes the id in the URL" do
|
||||
expect(child_category.url_with_id).to eq("/c/cats/dogs/#{child_category.id}")
|
||||
|
||||
Reference in New Issue
Block a user