mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
FIX: No small action created when a non-author removes itself from a PM (#20502)
Fixes a small issue where allowed user removes themselves from a private message before the post activity (small action) is created. I also added some test coverage to prevent regression. /t/92811
This commit is contained in:
@ -3081,6 +3081,17 @@ RSpec.describe Topic do
|
||||
|
||||
describe "#remove_allowed_user" do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:private_topic) do
|
||||
Fabricate(
|
||||
:private_message_topic,
|
||||
title: "Private message",
|
||||
user: admin,
|
||||
topic_allowed_users: [
|
||||
Fabricate.build(:topic_allowed_user, user: admin),
|
||||
Fabricate.build(:topic_allowed_user, user: user1),
|
||||
],
|
||||
)
|
||||
end
|
||||
|
||||
describe "removing oneself" do
|
||||
it "should remove onself" do
|
||||
@ -3095,6 +3106,12 @@ RSpec.describe Topic do
|
||||
expect(post.post_type).to eq(Post.types[:small_action])
|
||||
expect(post.action_code).to eq("user_left")
|
||||
end
|
||||
|
||||
it "should show a small action when user removes themselves from pm" do
|
||||
expect do private_topic.remove_allowed_user(user1, user1) end.to change {
|
||||
private_topic.posts.where(action_code: "user_left").count
|
||||
}.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user