FIX: Ensure staff can see /tag/none (#11208)
TopicQueryParams#build_topic_list_options changes params which could lead to options[:no_tags] and options[:tags] be set simultaneously.
This commit is contained in:
parent
2910996feb
commit
74a118c13a
|
@ -453,6 +453,7 @@ class TagsController < ::ApplicationController
|
||||||
options[:no_subcategories] = true if params[:no_subcategories] == 'true'
|
options[:no_subcategories] = true if params[:no_subcategories] == 'true'
|
||||||
|
|
||||||
if params[:tag_id] == 'none'
|
if params[:tag_id] == 'none'
|
||||||
|
options.delete(:tags)
|
||||||
options[:no_tags] = true
|
options[:no_tags] = true
|
||||||
else
|
else
|
||||||
options[:tags] = tag_params
|
options[:tags] = tag_params
|
||||||
|
|
|
@ -123,6 +123,8 @@ describe TagsController do
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
fab!(:tag) { Fabricate(:tag, name: 'test') }
|
fab!(:tag) { Fabricate(:tag, name: 'test') }
|
||||||
|
fab!(:topic_without_tags) { Fabricate(:topic) }
|
||||||
|
fab!(:topic_with_tags) { Fabricate(:topic, tags: [tag]) }
|
||||||
|
|
||||||
it "should return the right response" do
|
it "should return the right response" do
|
||||||
get "/tag/test.json"
|
get "/tag/test.json"
|
||||||
|
@ -162,6 +164,15 @@ describe TagsController do
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "handles special tag 'none'" do
|
||||||
|
SiteSetting.allow_staff_to_tag_pms = true
|
||||||
|
|
||||||
|
sign_in(admin)
|
||||||
|
|
||||||
|
get "/tag/none.json"
|
||||||
|
expect(response.parsed_body['topic_list']['topics'].length).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
context "with a category in the path" do
|
context "with a category in the path" do
|
||||||
fab!(:topic_in_category) {
|
fab!(:topic_in_category) {
|
||||||
Fabricate(
|
Fabricate(
|
||||||
|
|
Loading…
Reference in New Issue