FIX: TL0 could not message group with everyone messageable_level (#19525)

The commits e62e93f83a77adfa80b38fbfecf82bbee14e12fe and
d6bd4ad7ee1d3bf43ba0a2bb1948f8f306b6177a caused a regression
to the behaviour added for
https://meta.discourse.org/t/allow-tl0-to-write-messages-to-staff-group-not-to-other-members-or-non-staff/124335,
which allowed a user to message a group with the messageable_level
set to Everyone even if they were TL0 (or otherwise did not reach
the appropriate trust level). This commit fixes the issue and adjusts
the spec to reflect the real scenario.

c.f. https://meta.discourse.org/t/tl0-cant-message-groups-with-messageable-level-everyone-recession/249205
This commit is contained in:
Martin Brennan
2022-12-20 13:11:14 +10:00
committed by GitHub
parent ae2153b330
commit 94b258deda
3 changed files with 20 additions and 5 deletions

View File

@ -639,6 +639,16 @@ RSpec.describe GroupsController do
get "/groups/#{group.name}/messageable.json"
expect(response.status).to eq(200)
body = response.parsed_body
expect(body["messageable"]).to eq(true)
group.update!(
messageable_level: Group::ALIAS_LEVELS[:only_admins],
)
get "/groups/#{group.name}/messageable.json"
expect(response.status).to eq(200)
body = response.parsed_body
expect(body["messageable"]).to eq(false)
end