From d95e4102c11bc2170595040c3290b62f05a342c2 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 7 Mar 2017 11:46:39 -0500 Subject: [PATCH] FIX: tags created in secured categories should not be forbidden outside those categories --- app/controllers/tags_controller.rb | 2 +- spec/controllers/tags_controller_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 92973a9dbf5..0af8be70a63 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -127,7 +127,7 @@ class TagsController < ::ApplicationController category = params[:categoryId] ? Category.find_by_id(params[:categoryId]) : nil tags_with_counts = DiscourseTagging.filter_allowed_tags( - self.class.tags_by_count(guardian, params.slice(:limit)), + Tag.tags_by_count_query(params.slice(:limit)), guardian, { for_input: params[:filterForInput], diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 75696f18ccd..fcfcdb754d6 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -121,6 +121,15 @@ describe TagsController do expect(json["results"].map{|j| j["id"]}.sort).to eq([]) expect(json["forbidden"]).to be_present end + + it "can return tags that are in secured categories but are allowed to be used" do + c = Fabricate(:private_category, group: Fabricate(:group)) + Fabricate(:topic, category: c, tags: [Fabricate(:tag, name: "cooltag")]) + xhr :get, :search, q: "cool" + expect(response).to be_success + json = ::JSON.parse(response.body) + expect(json["results"].map{|j| j["id"]}).to eq(['cooltag']) + end end end end