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:
Dan Ungureanu
2020-01-10 17:02:36 +02:00
committed by GitHub
parent 6e480392ea
commit 815116f6a2
2 changed files with 25 additions and 1 deletions

View File

@ -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", {