2016-01-26 14:01:56 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe SpamLog, models: true 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
|
|
|
|
|
|
|
|
Sidekiq::Testing.inline! do
|
|
|
|
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
|