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:
@@ -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"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user