mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: Make 'findBySlugPathWithID' when URL ends with a slash (#8699)
Make URLs such as 'https://discourse/c/foo/bar/' work the same way 'https://discourse/c/foo/bar' does.
This commit is contained in:
@ -184,6 +184,30 @@ QUnit.test("findSingleBySlug", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("findBySlugPathWithID", assert => {
|
||||
const store = createStore();
|
||||
|
||||
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
||||
const bar = store.createRecord("category", {
|
||||
id: 2,
|
||||
slug: "bar",
|
||||
parentCategory: foo
|
||||
});
|
||||
const baz = store.createRecord("category", {
|
||||
id: 3,
|
||||
slug: "baz",
|
||||
parentCategory: foo
|
||||
});
|
||||
|
||||
const categoryList = [foo, bar, baz];
|
||||
sandbox.stub(Category, "list").returns(categoryList);
|
||||
|
||||
assert.deepEqual(Category.findBySlugPathWithID("foo"), foo);
|
||||
assert.deepEqual(Category.findBySlugPathWithID("foo/bar"), bar);
|
||||
assert.deepEqual(Category.findBySlugPathWithID("foo/bar/"), bar);
|
||||
assert.deepEqual(Category.findBySlugPathWithID("foo/baz/3"), baz);
|
||||
});
|
||||
|
||||
QUnit.test("search with category name", assert => {
|
||||
const store = createStore(),
|
||||
category1 = store.createRecord("category", {
|
||||
|
Reference in New Issue
Block a user