FIX: ensures category url of category drop is built using slug and id (#9069)
This commit is contained in:
parent
ff5ff8d0d2
commit
2db8ada222
|
@ -155,18 +155,16 @@ export default ComboBoxComponent.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onChange(value) {
|
onChange(categoryId) {
|
||||||
let categoryURL;
|
let categoryURL;
|
||||||
|
|
||||||
if (value === ALL_CATEGORIES_ID) {
|
if (categoryId === ALL_CATEGORIES_ID) {
|
||||||
categoryURL = this.allCategoriesUrl;
|
categoryURL = this.allCategoriesUrl;
|
||||||
} else if (value === NO_CATEGORIES_ID) {
|
} else if (categoryId === NO_CATEGORIES_ID) {
|
||||||
categoryURL = this.noCategoriesUrl;
|
categoryURL = this.noCategoriesUrl;
|
||||||
} else {
|
} else {
|
||||||
const categoryId = parseInt(value, 10);
|
const category = Category.findById(parseInt(categoryId, 10));
|
||||||
const category = Category.findById(categoryId);
|
categoryURL = category.url;
|
||||||
const slug = Discourse.Category.slugFor(category);
|
|
||||||
categoryURL = `/c/${slug}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscourseURL.routeToUrl(categoryURL);
|
DiscourseURL.routeToUrl(categoryURL);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import componentTest from "helpers/component-test";
|
import componentTest from "helpers/component-test";
|
||||||
import { testSelectKitModule } from "./select-kit-test-helper";
|
import { testSelectKitModule } from "./select-kit-test-helper";
|
||||||
|
@ -335,3 +336,22 @@ componentTest(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
componentTest("category url", {
|
||||||
|
template: template(),
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
initCategoriesWithParentCategory(this);
|
||||||
|
sandbox.stub(DiscourseURL, "routeTo");
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
await this.subject.expand();
|
||||||
|
await this.subject.selectRowByValue(26);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
DiscourseURL.routeTo.calledWith("/c/feature/spec/26"),
|
||||||
|
"it builds a correct URL"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue