FIX: whisper's presence channels (#30097)

In 0993273 we introduced the `whisper_allowed_group_ids` to allow whispers to more users than "staff".

The presence plugin hadn't been updated to account for this change.
This commit is contained in:
Régis Hanol
2024-12-04 11:47:05 +01:00
committed by GitHub
parent ad7a64b983
commit 3e7f0867ea
2 changed files with 19 additions and 8 deletions

View File

@ -118,15 +118,20 @@ RSpec.describe "discourse-presence" do
it "handles permissions for whispers" do
c = PresenceChannel.new("/discourse-presence/whisper/#{public_topic.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_group_ids).to contain_exactly(
*SiteSetting.whispers_allowed_groups_map,
)
expect(c.config.allowed_user_ids).to eq(nil)
end
it "only allows staff when editing whispers" do
it "correctly allows whisperers when editing whispers" do
p = Fabricate(:whisper, topic: public_topic, user: admin)
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_group_ids).to contain_exactly(
Group::AUTO_GROUPS[:staff],
*SiteSetting.whispers_allowed_groups_map,
)
expect(c.config.allowed_user_ids).to eq(nil)
end