mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FEATURE: Introduce site setting to allow for non staff pm tagging (#16671)
Currently the only way to allow tagging on pms is to use the `allow_staff_to_tag_pms` site setting. We are removing that site setting and replacing it with `pm_tags_allowed_for_groups` which will allow for non staff tagging. It will be group based permissions instead of requiring the user to be staff. If the existing value of `allow_staff_to_tag_pms` is `true` then we include the `staff` groups as a default for `pm_tags_allowed_for_groups`.
This commit is contained in:
@ -14,6 +14,7 @@ describe TopicViewSerializer do
|
||||
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user_2) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
|
||||
describe '#featured_link and #featured_link_root_domain' do
|
||||
@ -198,9 +199,17 @@ describe TopicViewSerializer do
|
||||
])
|
||||
end
|
||||
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:pm_between_reg_users) do
|
||||
Fabricate(:private_message_topic, tags: [tag], topic_allowed_users: [
|
||||
Fabricate.build(:topic_allowed_user, user: user),
|
||||
Fabricate.build(:topic_allowed_user, user: user_2)
|
||||
])
|
||||
end
|
||||
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.allow_staff_to_tag_pms = true
|
||||
SiteSetting.pm_tags_allowed_for_groups = "1|2|3|4"
|
||||
end
|
||||
|
||||
it "should not include the tag for normal users" do
|
||||
@ -215,8 +224,19 @@ describe TopicViewSerializer do
|
||||
end
|
||||
end
|
||||
|
||||
it "should include the tag for users in allowed groups" do
|
||||
SiteSetting.pm_tags_allowed_for_groups = "1|2|3|#{group.id}"
|
||||
|
||||
user.group_users << Fabricate(:group_user, group: group, user: user)
|
||||
json = serialize_topic(pm_between_reg_users, user)
|
||||
expect(json[:tags]).to eq([tag.name])
|
||||
|
||||
json = serialize_topic(pm_between_reg_users, user_2)
|
||||
expect(json[:tags]).to eq(nil)
|
||||
end
|
||||
|
||||
it "should not include the tag if pm tags disabled" do
|
||||
SiteSetting.allow_staff_to_tag_pms = false
|
||||
SiteSetting.pm_tags_allowed_for_groups = ""
|
||||
|
||||
[moderator, admin].each do |user|
|
||||
json = serialize_topic(pm, user)
|
||||
|
Reference in New Issue
Block a user