FIX: group tag notifications included for all users

Regression from my last commit
This commit is contained in:
Neil Lalonde 2020-09-16 16:02:28 -04:00
parent 04be39ed46
commit b207842720
No known key found for this signature in database
GPG Key ID: FF871CA9037D0A91
2 changed files with 10 additions and 1 deletions

View File

@ -101,7 +101,8 @@ class GroupShowSerializer < BasicGroupSerializer
end
define_method("include_#{level}_tags?") do
SiteSetting.tagging_enabled?
SiteSetting.tagging_enabled? &&
scope.is_admin? || (include_is_group_owner? && is_group_owner)
end
define_method("#{level}_tags") do

View File

@ -91,6 +91,8 @@ describe GroupShowSerializer do
let(:tag2) { Fabricate(:tag) }
before do
SiteSetting.tagging_enabled = true
GroupCategoryNotificationDefault.create!(
group: group,
category: category1,
@ -138,6 +140,12 @@ describe GroupShowSerializer do
expect(subject.as_json[:regular_tags]).to eq([])
expect(subject.as_json[:muted_tags]).to eq([])
end
it "doesn't include tag fields if tags are disabled" do
SiteSetting.tagging_enabled = false
expect(subject.as_json.keys.select { |k| k.to_s.ends_with?("_category_ids") }.length).to eq(5)
expect(subject.as_json.keys.select { |k| k.to_s.ends_with?("_tags") }).to be_empty
end
end
end
end