1
0
mirror of synced 2026-05-22 15:03:15 +00:00

FEATURE: add tag-based gated content (#13)

* add tags + minor css change

* Update settings.yml

* fix tag filtering

* change var scope

* FIX: Allow for topics with no tags

Topics will sometimes have a null amount of tags. This change allows for those situations.

* DEV: Add tests for gated tags

* Joffrey's idiotmatic way

Co-authored-by: David Taylor <david@taylorhq.com>
Co-authored-by: Jamie Wilson <jamie.wilson@discourse.org>
This commit is contained in:
chapoi
2022-09-02 15:56:41 +02:00
committed by GitHub
parent 45d2c95431
commit beaccbb89a
5 changed files with 60 additions and 25 deletions
+26 -2
View File
@@ -2,13 +2,16 @@ import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
acceptance("Gated Category - Anonymous", function (needs) {
acceptance("Gated Topics - Anonymous", function (needs) {
needs.settings({ tagging_enabled: true });
needs.hooks.beforeEach(() => {
settings.enabled_categories = "2";
settings.enabled_tags = "foo|baz";
});
needs.hooks.afterEach(() => {
settings.enabled_categories = "";
settings.enabled_tags = "";
});
test("Viewing Topic in gated category", async function (assert) {
@@ -28,16 +31,28 @@ acceptance("Gated Category - Anonymous", function (needs) {
"gated category prompt shown for anons on selected category"
);
});
test("Viewing Topic with gated tag", async function (assert) {
await visit("/t/2480");
assert.ok(
query(".topic-in-gated-category .custom-gated-topic-content"),
"gated category prompt shown for anons on topic with selected tag"
);
});
});
acceptance("Gated Category - Logged In", function (needs) {
acceptance("Gated Topics - Logged In", function (needs) {
needs.user();
needs.settings({ tagging_enabled: true });
needs.hooks.beforeEach(() => {
settings.enabled_categories = "2";
settings.enabled_tags = "foo|baz";
});
needs.hooks.afterEach(() => {
settings.enabled_categories = "";
settings.enabled_tags = "";
});
test("Viewing Topic in gated category", async function (assert) {
@@ -48,4 +63,13 @@ acceptance("Gated Category - Logged In", function (needs) {
"gated category prompt not shown on selected category"
);
});
test("Viewing Topic with gated tag", async function (assert) {
await visit("/t/2480");
assert.notOk(
query(".topic-in-gated-category .custom-gated-topic-content"),
"gated category prompt not shown on topic with selected tag"
);
});
});