Remove profile when banish (#15818)
* Clear profile when banishing user * Add test for clearing profile when banishing * Also clear any social usernames
This commit is contained in:
parent
329f33448f
commit
6335f9a7e9
2 changed files with 18 additions and 0 deletions
|
|
@ -46,6 +46,11 @@ module Users
|
|||
user.credits.delete_all
|
||||
user.organization_memberships.delete_all
|
||||
user.profile_pins.delete_all
|
||||
user.profile.update(summary: "", location: "", website_url: "", data: {})
|
||||
user.github_username = ""
|
||||
user.twitter_username = ""
|
||||
user.facebook_username = ""
|
||||
user.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,19 @@ RSpec.describe Moderator::BanishUser, type: :service do
|
|||
expect(user.username).to include "spam_"
|
||||
end
|
||||
|
||||
it "clears their profile" do
|
||||
sidekiq_perform_enqueued_jobs do
|
||||
described_class.call(user: user, admin: admin)
|
||||
end
|
||||
expect(user.profile.summary).to be_blank
|
||||
expect(user.profile.location).to be_blank
|
||||
expect(user.profile.website_url).to be_blank
|
||||
expect(user.profile.data).to be_empty
|
||||
expect(user.github_username).to be_blank
|
||||
expect(user.twitter_username).to be_blank
|
||||
expect(user.facebook_username).to be_blank
|
||||
end
|
||||
|
||||
it "removes all their articles" do
|
||||
create(:article, user: user, published: true)
|
||||
sidekiq_perform_enqueued_jobs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue