2021-10-27 15:23:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
require_migration!
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe ConfirmSecurityBot, :migration, feature_category: :users do
|
2021-10-27 15:23:28 +05:30
|
|
|
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
|