FIX: Assigning a user without notes assigns and closes the modal (#329)
This commit is contained in:
parent
fbdfb7143b
commit
5503499514
|
@ -19,6 +19,9 @@ export default Controller.extend({
|
||||||
this.allowedGroups = [];
|
this.allowedGroups = [];
|
||||||
|
|
||||||
ajax("/assign/suggestions").then((data) => {
|
ajax("/assign/suggestions").then((data) => {
|
||||||
|
if (this.isDestroying || this.isDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.set("assignSuggestions", data.suggestions);
|
this.set("assignSuggestions", data.suggestions);
|
||||||
this.set("allowedGroups", data.assign_allowed_on_groups);
|
this.set("allowedGroups", data.assign_allowed_on_groups);
|
||||||
this.set("allowedGroupsForAssignment", data.assign_allowed_for_groups);
|
this.set("allowedGroupsForAssignment", data.assign_allowed_for_groups);
|
||||||
|
@ -100,6 +103,10 @@ export default Controller.extend({
|
||||||
"model.allowedGroups": this.taskActions.allowedGroups,
|
"model.allowedGroups": this.taskActions.allowedGroups,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
return this.assign();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
import EmberObject from "@ember/object";
|
||||||
|
import pretender from "discourse/tests/helpers/create-pretender";
|
||||||
|
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { test } from "qunit";
|
||||||
|
import { Promise } from "rsvp";
|
||||||
|
|
||||||
|
discourseModule("Unit | Controller | assign-user", function () {
|
||||||
|
test("doesn't set suggestions and fails gracefully if controller is destroyed", function (assert) {
|
||||||
|
let resolveSuggestions;
|
||||||
|
pretender.get("/assign/suggestions", () => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
resolveSuggestions = resolve;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const controller = this.getController("assign-user", {
|
||||||
|
model: {
|
||||||
|
target: EmberObject.create({}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
controller.destroy();
|
||||||
|
resolveSuggestions([
|
||||||
|
200,
|
||||||
|
{ "Content-Type": "application/json" },
|
||||||
|
{
|
||||||
|
suggestions: [],
|
||||||
|
assign_allowed_on_groups: ["nat"],
|
||||||
|
assign_allowed_for_groups: [],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.strictEqual(controller.get("assign_allowed_on_groups"), undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("assigning a user closes the modal", function (assert) {
|
||||||
|
pretender.get("/assign/suggestions", () => {
|
||||||
|
return [
|
||||||
|
200,
|
||||||
|
{ "Content-Type": "application/json" },
|
||||||
|
{
|
||||||
|
suggestions: [],
|
||||||
|
assign_allowed_on_groups: ["nat"],
|
||||||
|
assign_allowed_for_groups: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
pretender.put("/assign/assign", () => {
|
||||||
|
return [200, { "Content-Type": "application/json" }, {}];
|
||||||
|
});
|
||||||
|
|
||||||
|
let modalClosed = false;
|
||||||
|
const controller = this.getController("assign-user", {
|
||||||
|
model: {
|
||||||
|
target: EmberObject.create({}),
|
||||||
|
},
|
||||||
|
allowedGroupsForAssignment: ["nat"],
|
||||||
|
taskActions: { allowedGroups: [] },
|
||||||
|
});
|
||||||
|
controller.set("actions.closeModal", () => {
|
||||||
|
modalClosed = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
controller.send("assignUser", "nat");
|
||||||
|
|
||||||
|
assert.strictEqual(modalClosed, true);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue