FIX: Don't reuse assign note when reassigning (#351)
This commit is contained in:
parent
169f13e239
commit
1ef8e70314
|
@ -38,7 +38,6 @@ export default Service.extend({
|
|||
group_name: target.assigned_to_group?.name,
|
||||
target,
|
||||
targetType: options.targetType,
|
||||
note: target.assignment_note,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
@ -50,7 +49,6 @@ export default Service.extend({
|
|||
username: user.username,
|
||||
target_id: target.id,
|
||||
target_type: targetType,
|
||||
note: target.assignment_note,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import sinon from "sinon";
|
||||
import * as showModal from "discourse/lib/show-modal";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
discourseModule("Unit | Service | task-actions", function () {
|
||||
test("assign", function (assert) {
|
||||
const stub = sinon.stub(showModal, "default").returns("the modal");
|
||||
const service = this.container.lookup("service:task-actions");
|
||||
const target = {
|
||||
assigned_to_user: { username: "tomtom" },
|
||||
assigned_to_group: { name: "cats" },
|
||||
};
|
||||
|
||||
const modal = service.assign(target);
|
||||
|
||||
const modalCall = stub.getCall(0).args;
|
||||
|
||||
assert.equal(modal, "the modal");
|
||||
assert.deepEqual(modalCall[0], "assign-user");
|
||||
assert.deepEqual(modalCall[1], {
|
||||
title: "discourse_assign.assign_modal.title",
|
||||
model: {
|
||||
description: "discourse_assign.assign_modal.description",
|
||||
reassign: false,
|
||||
username: "tomtom",
|
||||
group_name: "cats",
|
||||
target,
|
||||
targetType: "Topic",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("reassignUserToTopic", async function (assert) {
|
||||
const service = this.container.lookup("service:task-actions");
|
||||
const target = { id: 1 };
|
||||
const user = { username: "tomtom" };
|
||||
let assignRequest;
|
||||
pretender.put("/assign/assign", (request) => {
|
||||
assignRequest = request;
|
||||
return [200];
|
||||
});
|
||||
|
||||
await service.reassignUserToTopic(user, target);
|
||||
|
||||
assert.strictEqual(
|
||||
assignRequest.requestBody,
|
||||
"username=tomtom&target_id=1&target_type=Topic"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue