mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 11:04:42 +08:00
FIX: Disable 'Create Topic' button if tag is staff-only. (#6984)
* FIX: Disable 'Create Topic' button if tag is staff-only. * FIX: Staff-only tags should always return 404.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import { replaceCurrentUser, acceptance } from "helpers/qunit-helpers";
|
||||
acceptance("Tags", { loggedIn: true });
|
||||
|
||||
QUnit.test("list the tags", async assert => {
|
||||
@ -92,3 +92,83 @@ QUnit.test("list the tags in groups", async assert => {
|
||||
"always uses lowercase URLs for mixed case tags"
|
||||
);
|
||||
});
|
||||
|
||||
test("new topic button is not available for staff-only tags", async assert => {
|
||||
/* global server */
|
||||
server.get("/tags/regular-tag/notifications", () => [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
{ tag_notification: { id: "regular-tag", notification_level: 1 } }
|
||||
]);
|
||||
|
||||
server.get("/tags/regular-tag/l/latest.json", () => [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
{
|
||||
users: [],
|
||||
primary_groups: [],
|
||||
topic_list: {
|
||||
can_create_topic: true,
|
||||
draft: null,
|
||||
draft_key: "new_topic",
|
||||
draft_sequence: 1,
|
||||
per_page: 30,
|
||||
tags: [
|
||||
{
|
||||
id: 1,
|
||||
name: "regular-tag",
|
||||
topic_count: 1
|
||||
}
|
||||
],
|
||||
topics: []
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
server.get("/tags/staff-only-tag/notifications", () => [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
{ tag_notification: { id: "staff-only-tag", notification_level: 1 } }
|
||||
]);
|
||||
|
||||
server.get("/tags/staff-only-tag/l/latest.json", () => [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
{
|
||||
users: [],
|
||||
primary_groups: [],
|
||||
topic_list: {
|
||||
can_create_topic: true,
|
||||
draft: null,
|
||||
draft_key: "new_topic",
|
||||
draft_sequence: 1,
|
||||
per_page: 30,
|
||||
tags: [
|
||||
{
|
||||
id: 1,
|
||||
name: "staff-only-tag",
|
||||
topic_count: 1,
|
||||
staff: true
|
||||
}
|
||||
],
|
||||
topics: []
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
replaceCurrentUser({ staff: false });
|
||||
|
||||
await visit("/tags/regular-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 0);
|
||||
|
||||
await visit("/tags/staff-only-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 1);
|
||||
|
||||
replaceCurrentUser({ staff: true });
|
||||
|
||||
await visit("/tags/regular-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 0);
|
||||
|
||||
await visit("/tags/staff-only-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 0);
|
||||
});
|
||||
|
Reference in New Issue
Block a user