Commit 16e58d1c authored by Doug Stull's avatar Doug Stull

Merge branch '292927-make-bot-confirmed' into 'master'

Make Security bot confirmed

See merge request gitlab-org/gitlab!67252
parents 906e9441 3e190323
# frozen_string_literal: true
class ConfirmSecurityBot < ActiveRecord::Migration[6.0]
class User < ActiveRecord::Base
self.table_name = 'users'
SECURITY_BOT_TYPE = 8
end
def up
User.where(user_type: User::SECURITY_BOT_TYPE, confirmed_at: nil)
.update_all(confirmed_at: Time.current)
end
# no-op
# Security Bot should be always confirmed
def down
end
end
8522eaf951d87de04aea82fe8e1a9577e6665c8d08245282239476e49b02bc7d
\ No newline at end of file
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe ConfirmSecurityBot, :migration do
let(:users) { table(:users) }
let(:user_type) { 8 }
context 'when bot is not created' do
it 'skips migration' do
migrate!
bot = users.find_by(user_type: user_type)
expect(bot).to be_nil
end
end
context 'when bot is confirmed' do
let(:bot) { table(:users).create!(user_type: user_type, confirmed_at: Time.current, projects_limit: 1) }
it 'skips migration' do
expect { migrate! }.not_to change { bot.reload.confirmed_at }
end
end
context 'when bot is not confirmed' do
let(:bot) { table(:users).create!(user_type: user_type, projects_limit: 1) }
it 'update confirmed_at' do
freeze_time do
expect { migrate! }.to change { bot.reload.confirmed_at }.from(nil).to(Time.current)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment