This will replace `enable_personal_messages` and `min_trust_to_send_messages`, this commit introduces the setting `personal_message_enabled_groups` and uses it in all places that `enable_personal_messages` and `min_trust_to_send_messages` currently apply. A migration is included to set `personal_message_enabled_groups` based on the following rules: * If `enable_personal_messages` was false, then set `personal_message_enabled_groups` to `3`, which is the staff auto group * If `min_trust_to_send_messages` is not default (1) and the above condition is false, then set the `personal_message_enabled_groups` setting to the appropriate auto group based on the trust level * Otherwise just set `personal_message_enabled_groups` to 11 which is the TL1 auto group After follow-up PRs to plugins using these old settings, we will be able to drop the old settings from core, in the meantime I've added DEPRECATED notices to their descriptions and added them to the deprecated site settings list. This commit also introduces a `_map` shortcut method definition for all `group_list` site settings, e.g. `SiteSetting.personal_message_enabled_groups` also has `SiteSetting.personal_message_enabled_groups_map` available, which automatically splits the setting by `|` and converts it into an array of integers.
117 lines
3.2 KiB
JavaScript
117 lines
3.2 KiB
JavaScript
import { render } from "@ember/test-helpers";
|
|
import Session from "discourse/models/session";
|
|
import Site from "discourse/models/site";
|
|
import TopicTrackingState from "discourse/models/topic-tracking-state";
|
|
import User from "discourse/models/user";
|
|
import { autoLoadModules } from "discourse/initializers/auto-load-modules";
|
|
import QUnit, { test } from "qunit";
|
|
import { setupRenderingTest as emberSetupRenderingTest } from "ember-qunit";
|
|
import { currentSettings } from "discourse/tests/helpers/site-settings";
|
|
import { injectServiceIntoService } from "discourse/pre-initializers/inject-discourse-objects";
|
|
|
|
export function setupRenderingTest(hooks) {
|
|
emberSetupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
if (!hooks.usingDiscourseModule) {
|
|
this.siteSettings = currentSettings();
|
|
this.registry ||= this.owner.__registry__;
|
|
this.container = this.owner;
|
|
}
|
|
|
|
this.site = Site.current();
|
|
this.session = Session.current();
|
|
|
|
const currentUser = User.create({
|
|
username: "eviltrout",
|
|
timezone: "Australia/Brisbane",
|
|
name: "Robin Ward",
|
|
admin: false,
|
|
moderator: false,
|
|
groups: [
|
|
{
|
|
id: 10,
|
|
automatic: true,
|
|
name: "trust_level_0",
|
|
display_name: "trust_level_0",
|
|
},
|
|
{
|
|
id: 11,
|
|
automatic: true,
|
|
name: "trust_level_1",
|
|
display_name: "trust_level_1",
|
|
},
|
|
],
|
|
});
|
|
this.currentUser = currentUser;
|
|
this.owner.unregister("service:current-user");
|
|
this.owner.register("service:current-user", currentUser, {
|
|
instantiate: false,
|
|
});
|
|
this.owner.inject("component", "currentUser", "service:current-user");
|
|
injectServiceIntoService({
|
|
app: this.owner.application,
|
|
property: "currentUser",
|
|
specifier: "service:current-user",
|
|
});
|
|
|
|
this.owner.unregister("service:topic-tracking-state");
|
|
this.owner.register(
|
|
"service:topic-tracking-state",
|
|
TopicTrackingState.create({ currentUser }),
|
|
{ instantiate: false }
|
|
);
|
|
injectServiceIntoService({
|
|
app: this.owner.application,
|
|
property: "topicTrackingState",
|
|
specifier: "service:topic-tracking-state",
|
|
});
|
|
|
|
autoLoadModules(this.owner, this.registry);
|
|
this.owner.lookup("service:store");
|
|
|
|
$.fn.autocomplete = function () {};
|
|
});
|
|
}
|
|
|
|
export default function (name, hooks, opts) {
|
|
if (opts === undefined) {
|
|
opts = hooks;
|
|
}
|
|
|
|
opts = opts || {};
|
|
|
|
if (opts.skip) {
|
|
return;
|
|
}
|
|
|
|
if (typeof opts.template === "string") {
|
|
let testName = QUnit.config.currentModule.name + " " + name;
|
|
// eslint-disable-next-line
|
|
console.warn(
|
|
`${testName} skipped; template must be compiled and not a string`
|
|
);
|
|
return;
|
|
}
|
|
|
|
test(name, async function (assert) {
|
|
if (opts.anonymous) {
|
|
this.owner.unregister("service:current-user");
|
|
}
|
|
|
|
if (opts.beforeEach) {
|
|
const store = this.owner.lookup("service:store");
|
|
await opts.beforeEach.call(this, store);
|
|
}
|
|
|
|
try {
|
|
await render(opts.template);
|
|
await opts.test.call(this, assert);
|
|
} finally {
|
|
if (opts.afterEach) {
|
|
await opts.afterEach.call(opts);
|
|
}
|
|
}
|
|
});
|
|
}
|