FIX: tags created in secured categories should not be forbidden outside those categories

This commit is contained in:
Neil Lalonde 2017-03-07 11:46:39 -05:00
parent dad57fa033
commit d95e4102c1
2 changed files with 10 additions and 1 deletions

View File

@ -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],

View File

@ -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