mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Separated 'trusted users can edit others' setting for trust level 3 & 4 (#21493)
This commit is contained in:
@@ -57,8 +57,8 @@ after_initialize do
|
||||
]
|
||||
end
|
||||
|
||||
if !topic.private_message? && SiteSetting.trusted_users_can_edit_others?
|
||||
config.allowed_group_ids << Group::AUTO_GROUPS[:trust_level_4]
|
||||
if !topic.private_message? && SiteSetting.edit_all_post_groups.present?
|
||||
config.allowed_group_ids += SiteSetting.edit_all_post_groups.split("|").map(&:to_i)
|
||||
end
|
||||
|
||||
if SiteSetting.enable_category_group_moderation? &&
|
||||
|
||||
@@ -66,7 +66,7 @@ RSpec.describe "discourse-presence" do
|
||||
end
|
||||
|
||||
it "handles category moderators for edit" do
|
||||
SiteSetting.trusted_users_can_edit_others = false
|
||||
SiteSetting.edit_all_post_groups = nil
|
||||
p = Fabricate(:post, topic: private_topic, user: private_topic.user)
|
||||
|
||||
c = PresenceChannel.new("/discourse-presence/edit/#{p.id}")
|
||||
@@ -79,6 +79,20 @@ RSpec.describe "discourse-presence" do
|
||||
expect(c.config.allowed_group_ids).to contain_exactly(Group::AUTO_GROUPS[:staff], group.id)
|
||||
end
|
||||
|
||||
it "adds edit_all_post_groups to the presence channel" do
|
||||
p = Fabricate(:post, topic: public_topic, user: user)
|
||||
g = Fabricate(:group)
|
||||
|
||||
SiteSetting.edit_all_post_groups = "#{Group::AUTO_GROUPS[:trust_level_1]}|#{g.id}"
|
||||
|
||||
c = PresenceChannel.new("/discourse-presence/edit/#{p.id}")
|
||||
expect(c.config.allowed_group_ids).to contain_exactly(
|
||||
Group::AUTO_GROUPS[:staff],
|
||||
Group::AUTO_GROUPS[:trust_level_1],
|
||||
g.id,
|
||||
)
|
||||
end
|
||||
|
||||
it "handles permissions for a public topic" do
|
||||
c = PresenceChannel.new("/discourse-presence/reply/#{public_topic.id}")
|
||||
expect(c.config.public).to eq(false)
|
||||
@@ -135,27 +149,13 @@ RSpec.describe "discourse-presence" do
|
||||
expect(c.config.allowed_user_ids).to contain_exactly(user.id)
|
||||
end
|
||||
|
||||
it "allows only author and staff when editing a public post with tl4 editing disabled" do
|
||||
SiteSetting.trusted_users_can_edit_others = false
|
||||
|
||||
p = Fabricate(:post, topic: public_topic, user: user)
|
||||
c = PresenceChannel.new("/discourse-presence/edit/#{p.id}")
|
||||
expect(c.config.public).to eq(false)
|
||||
expect(c.config.allowed_group_ids).to contain_exactly(Group::AUTO_GROUPS[:staff])
|
||||
expect(c.config.allowed_user_ids).to contain_exactly(user.id)
|
||||
end
|
||||
|
||||
it "follows the wiki edit trust level site setting" do
|
||||
p = Fabricate(:post, topic: public_topic, user: user, wiki: true)
|
||||
SiteSetting.min_trust_to_edit_wiki_post = TrustLevel.levels[:basic]
|
||||
SiteSetting.trusted_users_can_edit_others = false
|
||||
|
||||
c = PresenceChannel.new("/discourse-presence/edit/#{p.id}")
|
||||
expect(c.config.public).to eq(false)
|
||||
expect(c.config.allowed_group_ids).to contain_exactly(
|
||||
Group::AUTO_GROUPS[:staff],
|
||||
Group::AUTO_GROUPS[:trust_level_1],
|
||||
)
|
||||
expect(c.config.allowed_group_ids).to include(Group::AUTO_GROUPS[:trust_level_1])
|
||||
expect(c.config.allowed_user_ids).to contain_exactly(user.id)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user