Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-04-17 00:54:41 +0300
committerStan Hu <stanhu@gmail.com>2017-04-18 03:17:31 +0300
commitfd605619361ce60500c58e5dffbbe8446cc25396 (patch)
treea59367e58c6de833878dbe7f267b0cd9945cc5a6 /spec/models
parentdbcfbd68b6b2b4c62ba5381317296b23002e3067 (diff)
Use DeleteUserWorker for removing users via spam logs
Before deleting a user via a SpamLog would just call `user.destroy`, which may omit other things that need to be cleaned up.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/spam_log_spec.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/models/spam_log_spec.rb b/spec/models/spam_log_spec.rb
index c4ec7625cb0..838fba6c92d 100644
--- a/spec/models/spam_log_spec.rb
+++ b/spec/models/spam_log_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
describe SpamLog, models: true do
+ let(:admin) { create(:admin) }
+
describe 'associations' do
it { is_expected.to belong_to(:user) }
end
@@ -13,13 +15,18 @@ describe SpamLog, models: true do
it 'blocks the user' do
spam_log = build(:spam_log)
- expect { spam_log.remove_user }.to change { spam_log.user.blocked? }.to(true)
+ expect { spam_log.remove_user(deleted_by: admin) }.to change { spam_log.user.blocked? }.to(true)
end
it 'removes the user' do
spam_log = build(:spam_log)
+ user = spam_log.user
+
+ Sidekiq::Testing.inline! do
+ spam_log.remove_user(deleted_by: admin)
+ end
- expect { spam_log.remove_user }.to change { User.count }.by(-1)
+ expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end