mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 05:43:16 +08:00
FIX: admins could never remove self from messages
This commit is contained in:
parent
6ddd8d9166
commit
4b449914b8
|
@ -698,6 +698,9 @@ SQL
|
|||
topic_user = topic_allowed_users.find_by(user_id: user.id)
|
||||
if topic_user
|
||||
topic_user.destroy
|
||||
# we can not remove ourselves cause then we will end up adding
|
||||
# ourselves in add_small_action
|
||||
removed_by = Discourse.system_user if user.id == removed_by.id
|
||||
add_small_action(removed_by, "removed_user", user.username)
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -1134,9 +1134,21 @@ describe TopicsController do
|
|||
xhr :put, :make_banner, topic_id: topic.id
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe 'remove_allowed_user' do
|
||||
it 'admin can be removed from a pm' do
|
||||
|
||||
admin = log_in :admin
|
||||
user = Fabricate(:user)
|
||||
pm = create_post(user: user, archetype: 'private_message', target_usernames: [user.username, admin.username])
|
||||
|
||||
xhr :put, :remove_allowed_user, topic_id: pm.topic_id, username: admin.username
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(TopicAllowedUser.where(topic_id: pm.topic_id, user_id: admin.id).first).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'remove_banner' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user