mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: Separated 'trusted users can edit others' setting for trust level 3 & 4 (#21493)
This commit is contained in:
@ -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