diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 22:43:44 -0500 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 22:43:44 -0500 |
commit | 555f50b3e68e82968ea2eb4916a3f5beeeef7b31 (patch) | |
tree | d4ca097c04ceb3c5ae5954bcce29ddd13c1d56d6 /spec/migrations | |
parent | 5595d73763caf224df4109ab2d52e616cd843d49 (diff) | |
download | gitlab-ce-555f50b3e68e82968ea2eb4916a3f5beeeef7b31.tar.gz |
Add more specs.36829-gpg-commit-not-verified-if-signed-with-a-subkey
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb b/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb new file mode 100644 index 00000000000..0e884a7d910 --- /dev/null +++ b/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys') + +describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do + matcher :be_scheduled_migration do |*expected| + match do |migration| + BackgroundMigrationWorker.jobs.any? do |job| + job['args'] == [migration, expected] + end + end + + failure_message do |migration| + "Migration `#{migration}` with args `#{expected.inspect}` not scheduled!" + end + end + + before do + create(:gpg_key, id: 1, key: GpgHelpers::User1.public_key) + create(:gpg_key, id: 2, key: GpgHelpers::User3.public_key) + # 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 + Sidekiq::Testing.inline! do + expect(GpgKeySubkey.count).to eq(0) + + migrate! + + expect(GpgKeySubkey.count).to eq(3) + end + end +end |