2016-01-26 14:01:56 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe SpamLog do
|
2017-04-16 17:54:41 -04:00
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
2016-01-26 14:01:56 -05:00
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:user) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:user) }
|
|
|
|
end
|
2016-01-26 16:20:01 -05:00
|
|
|
|
|
|
|
describe '#remove_user' do
|
|
|
|
it 'blocks the user' do
|
|
|
|
spam_log = build(:spam_log)
|
|
|
|
|
2017-04-16 17:54:41 -04:00
|
|
|
expect { spam_log.remove_user(deleted_by: admin) }.to change { spam_log.user.blocked? }.to(true)
|
2016-01-26 16:20:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes the user' do
|
|
|
|
spam_log = build(:spam_log)
|
2017-04-16 17:54:41 -04:00
|
|
|
user = spam_log.user
|
|
|
|
|
2018-07-23 00:34:54 -04:00
|
|
|
perform_enqueued_jobs do
|
2017-04-16 17:54:41 -04:00
|
|
|
spam_log.remove_user(deleted_by: admin)
|
|
|
|
end
|
2016-01-26 16:20:01 -05:00
|
|
|
|
2017-04-16 17:54:41 -04:00
|
|
|
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
|
2016-01-26 16:20:01 -05:00
|
|
|
end
|
|
|
|
end
|
2016-01-26 14:01:56 -05:00
|
|
|
end
|