summaryrefslogtreecommitdiff
path: root/spec/migrations/20230309071242_delete_security_policy_bot_users_spec.rb
blob: 4dd44cad1589e37123558b34f314c21bd19b2cfd (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
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe DeleteSecurityPolicyBotUsers, feature_category: :security_policy_management do
  let(:users) { table(:users) }

  before do
    users.create!(user_type: 10, projects_limit: 0, email: 'security_policy_bot@example.com')
    users.create!(user_type: 1, projects_limit: 0, email: 'support_bot@example.com')
    users.create!(projects_limit: 0, email: 'human@example.com')
  end

  describe '#up' do
    it 'deletes security_policy_bot users' do
      expect { migrate! }.to change { users.count }.by(-1)

      expect(users.where(user_type: 10).count).to eq(0)
      expect(users.where(user_type: 1).count).to eq(1)
      expect(users.where(user_type: nil).count).to eq(1)
    end
  end
end