FIX: an existing member of a channel is allowed to join (#26884)

There's no point checking if a user can join a channel if they are already part of it. This case was frequent when using `enforce_membership: true` for custom bots for example.
This commit is contained in:
Joffrey JAFFEUX
2024-05-06 17:14:20 +02:00
committed by GitHub
parent 00d88766b2
commit f72f63660a
3 changed files with 10 additions and 2 deletions

View File

@ -227,9 +227,15 @@ RSpec.describe Chat::CreateMessage do
context "when channel model is found" do
context "when user can't join channel" do
let(:guardian) { Guardian.new }
let(:guardian) { other_user.guardian }
it { is_expected.to fail_a_policy(:allowed_to_join_channel) }
context "when the user is already member of the channel" do
before { channel.add(guardian.user) }
it { is_expected.to be_a_success }
end
end
context "when user is system" do