mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 18:05:48 +08:00
FIX: Editing tags in sidebar should show all tags visible to user (#22628)
Why this change? Prior to this change, we would only return tags that are used in at least one public topic. However, this is confusing for users because the tag could be used in a restricted category and that is not considered a "public" topic. Instead, we will just display all the tags in the edit tags navigation modal as long as it is visible to the user.
This commit is contained in:
parent
07c3782e51
commit
37fd05af4e
|
@ -104,7 +104,7 @@ class TagsController < ::ApplicationController
|
||||||
|
|
||||||
def list
|
def list
|
||||||
offset = params[:offset].to_i || 0
|
offset = params[:offset].to_i || 0
|
||||||
tags = guardian.can_admin_tags? ? Tag.all : Tag.used_tags_in_regular_topics(guardian)
|
tags = guardian.can_admin_tags? ? Tag.all : Tag.visible(guardian)
|
||||||
|
|
||||||
load_more_query_params = { offset: offset + 1 }
|
load_more_query_params = { offset: offset + 1 }
|
||||||
|
|
||||||
|
|
|
@ -1443,20 +1443,16 @@ RSpec.describe TagsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#list" do
|
describe "#list" do
|
||||||
fab!(:tag3) do
|
fab!(:tag3) { Fabricate(:tag, name: "tag3") }
|
||||||
Fabricate(:tag, name: "tag3").tap { |tag| Fabricate.times(1, :topic, tags: [tag]) }
|
fab!(:tag2) { Fabricate(:tag, name: "tag2") }
|
||||||
end
|
fab!(:tag1) { Fabricate(:tag, name: "tag") }
|
||||||
|
|
||||||
fab!(:tag2) do
|
fab!(:staff_only_tag) { Fabricate(:tag, name: "tag4") }
|
||||||
Fabricate(:tag, name: "tag2").tap { |tag| Fabricate.times(1, :topic, tags: [tag]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
fab!(:tag1) do
|
let!(:staff_tag_group) do
|
||||||
Fabricate(:tag, name: "tag").tap { |tag| Fabricate.times(1, :topic, tags: [tag]) }
|
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [staff_only_tag.name])
|
||||||
end
|
end
|
||||||
|
|
||||||
fab!(:tag_not_used_in_topics) { Fabricate(:tag, name: "tag4") }
|
|
||||||
|
|
||||||
it "should return 403 for an anonymous user" do
|
it "should return 403 for an anonymous user" do
|
||||||
get "/tags/list.json"
|
get "/tags/list.json"
|
||||||
|
|
||||||
|
@ -1473,7 +1469,7 @@ RSpec.describe TagsController do
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should only return tags used in topics for non admin users" do
|
it "should only return tags that are visible to the user for non admin users" do
|
||||||
stub_const(TagsController, "LIST_LIMIT", 2) do
|
stub_const(TagsController, "LIST_LIMIT", 2) do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
|
||||||
|
@ -1525,7 +1521,7 @@ RSpec.describe TagsController do
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
expect(response.parsed_body["list_tags"].map { |tag| tag["name"] }).to eq(
|
expect(response.parsed_body["list_tags"].map { |tag| tag["name"] }).to eq(
|
||||||
[tag3.name, tag_not_used_in_topics.name],
|
[tag3.name, staff_only_tag.name],
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(response.parsed_body["meta"]["total_rows_list_tags"]).to eq(4)
|
expect(response.parsed_body["meta"]["total_rows_list_tags"]).to eq(4)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user