Clean up chat channels when deleting users (#6225)
This commit is contained in:
parent
207621f739
commit
c9b641928f
2 changed files with 17 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ module Users
|
|||
user.follows.delete_all
|
||||
Follow.where(followable_id: user.id, followable_type: "User").delete_all
|
||||
user.messages.delete_all
|
||||
user.chat_channel_memberships.delete_all
|
||||
Users::CleanupChatChannels.call(user)
|
||||
user.mentions.delete_all
|
||||
user.badge_achievements.delete_all
|
||||
user.github_repos.delete_all
|
||||
|
|
|
|||
|
|
@ -86,4 +86,20 @@ RSpec.describe Users::Delete, type: :service do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when cleaning up chat channels" do
|
||||
let_it_be(:other_user) { create(:user) }
|
||||
|
||||
it "deletes the user's private chat channels" do
|
||||
chat_channel = ChatChannel.create_with_users([user, other_user])
|
||||
described_class.call(user)
|
||||
expect(ChatChannel.find_by(id: chat_channel.id)).to be_nil
|
||||
end
|
||||
|
||||
it "does not delete the user's open channels" do
|
||||
chat_channel = ChatChannel.create_with_users([user, other_user], "open")
|
||||
described_class.call(user)
|
||||
expect(ChatChannel.find_by(id: chat_channel.id)).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue