diff --git a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 index d2fa1aeac12..d474c9b6e51 100644 --- a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 +++ b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 @@ -64,33 +64,29 @@ export default Ember.Controller.extend(ModalFunctionality, { actions: { saveCategory() { - const model = this.get("model"); - - const parentCategory = this.site - .get("categories") - .findBy("id", parseInt(model.get("parent_category_id"), 10)); + const self = this, + model = this.get("model"), + parentCategory = this.site + .get("categories") + .findBy("id", parseInt(model.get("parent_category_id"), 10)); this.set("saving", true); model.set("parentCategory", parentCategory); - model + this.get("model") .save() - .then(result => { - this.set("saving", false); - + .then(function(result) { + self.set("saving", false); + self.send("closeModal"); model.setProperties({ slug: result.category.slug, id: result.category.id }); - - if (this.get("selectedTab") !== "settings") { - this.send("closeModal"); - DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model)); - } + DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model)); }) - .catch(error => { - this.flash(extractError(error), "error"); - this.set("saving", false); + .catch(function(error) { + self.flash(extractError(error), "error"); + self.set("saving", false); }); }, diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6 index 18a7410c18d..968fb58f572 100644 --- a/test/javascripts/acceptance/category-edit-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-test.js.es6 @@ -3,17 +3,7 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Category Edit", { loggedIn: true, - settings: { email_in: true }, - pretend(server, helper) { - server.post("/categories", () => { - return helper.response({ - category: { - slug: "bug", - id: 999 - } - }); - }); - } + settings: { email_in: true } }); QUnit.test("Can open the category modal", async assert => { @@ -28,25 +18,21 @@ QUnit.test("Can open the category modal", async assert => { QUnit.test("Editing the category", async assert => { await visit("/c/bug"); - await click(".edit-category"); - await click(".edit-category-settings a"); + await click(".edit-category"); + await fillIn("#edit-text-color", "#ff0000"); + + await click(".edit-category-topic-template"); + await fillIn(".d-editor-input", "this is the new topic template"); + + await click(".edit-category-settings"); const searchPriorityChooser = selectKit("#category-search-priority"); await searchPriorityChooser.expand(); await searchPriorityChooser.selectRowByValue(1); - await click("#save-category"); - assert.ok(visible(".d-modal"), "it does not close the modal"); - - await click(".edit-category-general a"); - await fillIn("#edit-text-color", "#ff0000"); - - await click(".edit-category-topic-template a"); - await fillIn(".d-editor-input", "this is the new topic template"); await click("#save-category"); assert.ok(!visible(".d-modal"), "it closes the modal"); - assert.equal( DiscourseURL.redirectedTo, "/c/bug",