diff options
Diffstat (limited to 'spec/workers/project_update_repository_storage_worker_spec.rb')
-rw-r--r-- | spec/workers/project_update_repository_storage_worker_spec.rb | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/spec/workers/project_update_repository_storage_worker_spec.rb b/spec/workers/project_update_repository_storage_worker_spec.rb index 57a4c2128b3..98856480b21 100644 --- a/spec/workers/project_update_repository_storage_worker_spec.rb +++ b/spec/workers/project_update_repository_storage_worker_spec.rb @@ -9,12 +9,40 @@ describe ProjectUpdateRepositoryStorageWorker do subject { described_class.new } describe "#perform" do - it "calls the update repository storage service" do - expect_next_instance_of(Projects::UpdateRepositoryStorageService) do |instance| - expect(instance).to receive(:execute).with('new_storage') + let(:service) { double(:update_repository_storage_service) } + + before do + allow(Gitlab.config.repositories.storages).to receive(:keys).and_return(%w[default test_second_storage]) + end + + context 'without repository storage move' do + it "calls the update repository storage service" do + expect(Projects::UpdateRepositoryStorageService).to receive(:new).and_return(service) + expect(service).to receive(:execute) + + expect do + subject.perform(project.id, 'test_second_storage') + end.to change(ProjectRepositoryStorageMove, :count).by(1) + + storage_move = project.repository_storage_moves.last + expect(storage_move).to have_attributes( + source_storage_name: "default", + destination_storage_name: "test_second_storage" + ) end + end + + context 'with repository storage move' do + let!(:repository_storage_move) { create(:project_repository_storage_move) } - subject.perform(project.id, 'new_storage') + it "calls the update repository storage service" do + expect(Projects::UpdateRepositoryStorageService).to receive(:new).and_return(service) + expect(service).to receive(:execute) + + expect do + subject.perform(nil, nil, repository_storage_move.id) + end.not_to change(ProjectRepositoryStorageMove, :count) + end end end end |