mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: default_tags_muted setting should work for anonymous users too.
This commit is contained in:
parent
54cf3c6766
commit
89fcb75af2
@ -908,11 +908,18 @@ class TopicQuery
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remove_muted_tags(list, user, opts = nil)
|
def remove_muted_tags(list, user, opts = nil)
|
||||||
if user.nil? || !SiteSetting.tagging_enabled || SiteSetting.remove_muted_tags_from_latest == 'never'
|
if !SiteSetting.tagging_enabled || SiteSetting.remove_muted_tags_from_latest == 'never'
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
|
||||||
muted_tag_ids = TagUser.lookup(user, :muted).pluck(:tag_id)
|
muted_tag_ids = []
|
||||||
|
|
||||||
|
if user.present?
|
||||||
|
muted_tag_ids = TagUser.lookup(user, :muted).pluck(:tag_id)
|
||||||
|
else
|
||||||
|
muted_tag_ids = SiteSetting.default_tags_muted.split("|").map(&:to_i)
|
||||||
|
end
|
||||||
|
|
||||||
if muted_tag_ids.blank?
|
if muted_tag_ids.blank?
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
@ -281,6 +281,19 @@ describe TopicQuery do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'remove_muted_tags' do
|
||||||
|
fab!(:topic) { Fabricate(:topic, tags: [tag]) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.remove_muted_tags_from_latest = 'always'
|
||||||
|
SiteSetting.default_tags_muted = tag.id.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'removes default muted tag topics for anonymous users' do
|
||||||
|
expect(TopicQuery.new(nil).list_latest.topics.map(&:id)).not_to include(topic.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "and categories too" do
|
context "and categories too" do
|
||||||
let(:category1) { Fabricate(:category_with_definition) }
|
let(:category1) { Fabricate(:category_with_definition) }
|
||||||
let(:category2) { Fabricate(:category_with_definition) }
|
let(:category2) { Fabricate(:category_with_definition) }
|
||||||
|
Loading…
Reference in New Issue
Block a user