diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-05-31 20:46:19 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-05-31 20:46:19 +0000 |
commit | 3e4862ac6d492807a0b2a6ba3dde819716dbfae1 (patch) | |
tree | a07f2c9b4f40afd7ab3b17256001f61d63b43ab5 /spec/migrations | |
parent | 523ed2e72962e97be2603ab78aa13b372da582fa (diff) | |
parent | f3efec202986f820eaa1dc76db34b095e73a99f6 (diff) | |
download | gitlab-ce-3e4862ac6d492807a0b2a6ba3dde819716dbfae1.tar.gz |
Merge branch 'osw-reset-merge-status-from-mergeable-mrs' into 'master'
Reset merge status from mergeable MRs
See merge request gitlab-org/gitlab-ce!28843
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/enqueue_reset_merge_status_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/migrations/enqueue_reset_merge_status_spec.rb b/spec/migrations/enqueue_reset_merge_status_spec.rb new file mode 100644 index 00000000000..0d5e33bfd46 --- /dev/null +++ b/spec/migrations/enqueue_reset_merge_status_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20190528180441_enqueue_reset_merge_status.rb') + +describe EnqueueResetMergeStatus, :migration, :sidekiq do + let(:namespaces) { table(:namespaces) } + let(:projects) { table(:projects) } + let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } + let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') } + let(:merge_requests) { table(:merge_requests) } + + def create_merge_request(id, extra_params = {}) + params = { + id: id, + target_project_id: project.id, + target_branch: 'master', + source_project_id: project.id, + source_branch: 'mr name', + title: "mr name#{id}" + }.merge(extra_params) + + merge_requests.create!(params) + end + + it 'correctly schedules background migrations' do + create_merge_request(1, state: 'opened', merge_status: 'can_be_merged') + create_merge_request(2, state: 'opened', merge_status: 'can_be_merged') + create_merge_request(3, state: 'opened', merge_status: 'can_be_merged') + create_merge_request(4, state: 'merged', merge_status: 'can_be_merged') + create_merge_request(5, state: 'opened', merge_status: 'unchecked') + + stub_const("#{described_class.name}::BATCH_SIZE", 2) + + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(5.minutes, 1, 2) + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(10.minutes, 3, 3) + + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + end + end + end +end |