mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
Previously, picking a group in the bulk assign modal always failed with a bodyless 500: the client only sent `username`, `group_name` was not a permitted bulk action parameter, and the bulk operation only ever resolved a `User` — so `Assigner` received `nil`, treated it as a `Group`, and crashed dereferencing it. This change routes both the bulk and single-topic paths through one `DiscourseAssign::AssigneeResolver`, makes `Assigner#assign` return a reason instead of raising for caller-supplied input, and surfaces per-topic refusals through `@errors` so a partially applied bulk assign explains itself instead of reporting success. Ref - t/188206
44 lines
1.4 KiB
Text
Vendored
44 lines
1.4 KiB
Text
Vendored
import { render, settled } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
|
import { i18n } from "discourse-i18n";
|
|
import BulkActionsAssignUser from "discourse/plugins/discourse-assign/discourse/components/bulk-actions/bulk-assign-user";
|
|
|
|
module("Integration | Component | BulkActionsAssignUser", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
pretender.get("/assign/suggestions", () =>
|
|
response({
|
|
suggestions: [],
|
|
assign_allowed_on_groups: [],
|
|
assign_allowed_for_groups: [],
|
|
})
|
|
);
|
|
});
|
|
|
|
test("does not submit when no assignee has been chosen", async function (assert) {
|
|
let registeredAction;
|
|
let performed = false;
|
|
const onRegisterAction = (callback) => (registeredAction = callback);
|
|
const onPerform = () => (performed = true);
|
|
|
|
await render(
|
|
<template>
|
|
<BulkActionsAssignUser
|
|
@onRegisterAction={{onRegisterAction}}
|
|
@onPerform={{onPerform}}
|
|
/>
|
|
</template>
|
|
);
|
|
|
|
await registeredAction();
|
|
await settled();
|
|
|
|
assert.false(performed, "no bulk operation is sent");
|
|
assert
|
|
.dom(".assignee-error .error-label")
|
|
.hasText(i18n("discourse_assign.assign_modal.choose_assignee"));
|
|
});
|
|
});
|