debian-mirror-gitlab/spec/models/spam_log_spec.rb

35 lines
792 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2016-04-02 18:10:28 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe SpamLog do
2017-08-17 22:00:37 +05:30
let(:admin) { create(:admin) }
2016-04-02 18:10:28 +05:30
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)
2017-08-17 22:00:37 +05:30
expect { spam_log.remove_user(deleted_by: admin) }.to change { spam_log.user.blocked? }.to(true)
2016-04-02 18:10:28 +05:30
end
2019-12-26 22:10:19 +05:30
it 'removes the user', :sidekiq_might_not_need_inline do
2016-04-02 18:10:28 +05:30
spam_log = build(:spam_log)
2017-08-17 22:00:37 +05:30
user = spam_log.user
2018-11-18 11:00:15 +05:30
perform_enqueued_jobs do
2017-08-17 22:00:37 +05:30
spam_log.remove_user(deleted_by: admin)
end
2016-04-02 18:10:28 +05:30
2017-08-17 22:00:37 +05:30
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
2016-04-02 18:10:28 +05:30
end
end
end