mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:45:06 +08:00
FIX: Do not error if admin/owner checks target message (#21721)
In the ChannelViewBuilder, we introduced a check to see if the target message exists, which errors if the message has been trashed. However if the user is the creator of the message or admin then they are able to see trashed messages, so we need to take this into account.
This commit is contained in:
@ -228,6 +228,18 @@ RSpec.describe Chat::ChannelViewBuilder do
|
||||
before { message.trash! }
|
||||
|
||||
it { is_expected.to fail_a_policy(:target_message_exists) }
|
||||
|
||||
context "when the user is the owner of the trashed message" do
|
||||
before { message.update!(user: current_user) }
|
||||
|
||||
it { is_expected.not_to fail_a_policy(:target_message_exists) }
|
||||
end
|
||||
|
||||
context "when the user is admin" do
|
||||
before { current_user.update!(admin: true) }
|
||||
|
||||
it { is_expected.not_to fail_a_policy(:target_message_exists) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user