gitlab-org--gitlab-foss/spec/models/spam_log_spec.rb
Stan Hu fd60561936 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.
2017-04-17 17:17:31 -07:00

32 lines
746 B
Ruby

require 'spec_helper'
describe SpamLog, models: true do
let(:admin) { create(:admin) }
describe 'associations' do
it { is_expected.to belong_to(:user) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:user) }
end
describe '#remove_user' do
it 'blocks the user' do
spam_log = build(:spam_log)
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 { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end