Skip to content

A platform for community discussion. Free, open, simple.

FIX: tag intersection not populating (#6296)

James Kieselb2ce33be267c
diff --git a/app/assets/javascripts/discourse/routes/tags-show.js.es6 b/app/assets/javascripts/discourse/routes/tags-show.js.es6
index 24e2326807c..437f3e4e821 100644
--- a/app/assets/javascripts/discourse/routes/tags-show.js.es6
+++ b/app/assets/javascripts/discourse/routes/tags-show.js.es6
@@ -184,9 +184,11 @@ export default Discourse.Route.extend({
var c = self.controllerFor("composer").get("model");
c.set(
"tags",
- _.flatten(
- [controller.get("model.id")],
- controller.get("additionalTags")
+ _.compact(
+ _.flatten([
+ controller.get("model.id"),
+ controller.get("additionalTags")
+ ])
)
);
}
diff --git a/test/javascripts/acceptance/tags-intersection-test.js.es6 b/test/javascripts/acceptance/tags-intersection-test.js.es6
new file mode 100644
index 00000000000..85787a68642
--- /dev/null
+++ b/test/javascripts/acceptance/tags-intersection-test.js.es6
@@ -0,0 +1,43 @@
+import { acceptance } from "helpers/qunit-helpers";
+
+acceptance("Tags intersection", {
+ loggedIn: true,
+ site: { can_tag_topics: true },
+ settings: { tagging_enabled: true },
+ pretend(server, helper) {
+ server.get("/tags/first/notifications", () => {
+ return helper.response({
+ tag_notification: { id: "first", notification_level: 1 }
+ });
+ });
+ server.get("/tags/intersection/first/second.json", () => {
+ return helper.response({
+ users: [],
+ primary_groups: [],
+ topic_list: {
+ can_create_topic: true,
+ draft_key: "new_topic",
+ topics: [{ id: 16, posters: [] }],
+ tags: [
+ { id: 1, name: "first", topic_count: 1 },
+ { id: 2, name: "second", topic_count: 1 }
+ ]
+ }
+ });
+ });
+ }
+});
+
+QUnit.test("Populate tags when creating new topic", async assert => {
+ await visit("/tags/intersection/first/second");
+ await click("#create-topic");
+
+ assert.ok(exists(".mini-tag-chooser"), "The tag selector appears");
+ assert.equal(
+ $(".mini-tag-chooser")
+ .text()
+ .trim(),
+ "first, second",
+ "populates the tags when clicking 'New topic'"
+ );
+});