2017-10-06 03:43:44 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'post_migrate', '20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys')
|
|
|
|
|
|
|
|
describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do
|
|
|
|
before do
|
2018-03-30 15:18:44 +00:00
|
|
|
create(:gpg_key, id: 1, key: GpgHelpers::User1.public_key) # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
create(:gpg_key, id: 2, key: GpgHelpers::User3.public_key) # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
2017-10-06 03:43:44 +00:00
|
|
|
# Delete all subkeys so they can be recreated
|
|
|
|
GpgKeySubkey.destroy_all
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly schedules background migrations' do
|
|
|
|
Sidekiq::Testing.fake! do
|
|
|
|
migrate!
|
|
|
|
|
|
|
|
expect(described_class::MIGRATION).to be_scheduled_migration(1)
|
|
|
|
expect(described_class::MIGRATION).to be_scheduled_migration(2)
|
|
|
|
expect(BackgroundMigrationWorker.jobs.size).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'schedules background migrations' do
|
2018-07-23 04:34:54 +00:00
|
|
|
perform_enqueued_jobs do
|
2017-10-06 03:43:44 +00:00
|
|
|
expect(GpgKeySubkey.count).to eq(0)
|
|
|
|
|
|
|
|
migrate!
|
|
|
|
|
|
|
|
expect(GpgKeySubkey.count).to eq(3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|