mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 03:32:45 +08:00
FIX: New general category changes preventing topic create (#18459)
* FIX: New general category changes preventing topic create Follow up to: #18383 The logic in the previous commit was checking for null, but we are seeding the SiteSetting.general_category_id with an id of -1 so we need to check for a positive value as well as checking for null. See: https://meta.discourse.org/t/240661 * Add js test for presence of category… dropdown option
This commit is contained in:
parent
a5fbdba9d4
commit
6affbabfd3
|
@ -145,7 +145,8 @@ const Composer = RestModel.extend({
|
||||||
if (isEmpty(categoryId)) {
|
if (isEmpty(categoryId)) {
|
||||||
// Set General as the default category
|
// Set General as the default category
|
||||||
const generalCategoryId = this.siteSettings.general_category_id;
|
const generalCategoryId = this.siteSettings.general_category_id;
|
||||||
categoryId = generalCategoryId ? generalCategoryId : null;
|
categoryId =
|
||||||
|
generalCategoryId && generalCategoryId > 0 ? generalCategoryId : null;
|
||||||
}
|
}
|
||||||
this._categoryId = categoryId;
|
this._categoryId = categoryId;
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,23 @@ module(
|
||||||
assert.strictEqual(this.subject.header().label(), "");
|
assert.strictEqual(this.subject.header().label(), "");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("with allowUncategorized=null and generalCategoryId present, but not set", async function (assert) {
|
||||||
|
this.siteSettings.allow_uncategorized_topics = false;
|
||||||
|
this.siteSettings.general_category_id = -1;
|
||||||
|
|
||||||
|
await render(hbs`
|
||||||
|
<CategoryChooser
|
||||||
|
@value={{this.value}}
|
||||||
|
@options={{hash
|
||||||
|
allowUncategorized=null
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
`);
|
||||||
|
|
||||||
|
assert.strictEqual(this.subject.header().value(), null);
|
||||||
|
assert.strictEqual(this.subject.header().label(), "category…");
|
||||||
|
});
|
||||||
|
|
||||||
test("with allowUncategorized=null none=true", async function (assert) {
|
test("with allowUncategorized=null none=true", async function (assert) {
|
||||||
this.siteSettings.allow_uncategorized_topics = false;
|
this.siteSettings.allow_uncategorized_topics = false;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default ComboBoxComponent.extend({
|
||||||
return Category.findUncategorized();
|
return Category.findUncategorized();
|
||||||
} else {
|
} else {
|
||||||
const generalCategoryId = this.siteSettings.general_category_id;
|
const generalCategoryId = this.siteSettings.general_category_id;
|
||||||
if (!generalCategoryId) {
|
if (!generalCategoryId || generalCategoryId < 0) {
|
||||||
return this.defaultItem(null, htmlSafe(I18n.t("category.choose")));
|
return this.defaultItem(null, htmlSafe(I18n.t("category.choose")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user