summaryrefslogtreecommitdiff
path: root/spec/workers/project_schedule_bulk_repository_shard_moves_worker_spec.rb
blob: aadfae51906dd14fcf85c47d844762eb582ea6c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ProjectScheduleBulkRepositoryShardMovesWorker do
  describe "#perform" do
    before do
      stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' })

      allow(ProjectUpdateRepositoryStorageWorker).to receive(:perform_async)
    end

    let!(:project) { create(:project, :repository).tap { |project| project.track_project_repository } }
    let(:source_storage_name) { 'default' }
    let(:destination_storage_name) { 'test_second_storage' }

    include_examples 'an idempotent worker' do
      let(:job_args) { [source_storage_name, destination_storage_name] }

      it 'schedules project repository storage moves' do
        expect { subject }.to change(ProjectRepositoryStorageMove, :count).by(1)

        storage_move = project.repository_storage_moves.last!

        expect(storage_move).to have_attributes(
          source_storage_name: source_storage_name,
          destination_storage_name: destination_storage_name,
          state_name: :scheduled
        )
      end
    end
  end
end