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

spam_log_spec.rb « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e9ea234f75dbe04e2efe826136ecfe9dbff1702e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require 'spec_helper'

describe SpamLog 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

      perform_enqueued_jobs do
        spam_log.remove_user(deleted_by: admin)
      end

      expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
    end
  end
end