diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/models/project_import_state_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/models/project_import_state_spec.rb')
-rw-r--r-- | spec/models/project_import_state_spec.rb | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/spec/models/project_import_state_spec.rb b/spec/models/project_import_state_spec.rb index 42ca8130734..f6e398bd23c 100644 --- a/spec/models/project_import_state_spec.rb +++ b/spec/models/project_import_state_spec.rb @@ -65,9 +65,11 @@ RSpec.describe ProjectImportState, type: :model do expect_next_instance_of(Gitlab::Import::Logger) do |logger| expect(logger).to receive(:error).with( - error: 'ActiveRecord::ActiveRecordError', - message: 'Error setting import status to failed', - original_error: error_message + { + error: 'ActiveRecord::ActiveRecordError', + message: 'Error setting import status to failed', + original_error: error_message + } ) end @@ -131,20 +133,6 @@ RSpec.describe ProjectImportState, type: :model do describe 'import state transitions' do context 'state transition: [:started] => [:finished]' do - let(:after_import_service) { spy(:after_import_service) } - let(:housekeeping_service) { spy(:housekeeping_service) } - - before do - allow(Projects::AfterImportService) - .to receive(:new) { after_import_service } - - allow(after_import_service) - .to receive(:execute) { housekeeping_service.execute } - - allow(Repositories::HousekeepingService) - .to receive(:new) { housekeeping_service } - end - it 'resets last_error' do error_message = 'Some error' import_state = create(:import_state, :started, last_error: error_message) @@ -152,29 +140,28 @@ RSpec.describe ProjectImportState, type: :model do expect { import_state.finish }.to change { import_state.last_error }.from(error_message).to(nil) end - it 'performs housekeeping when an import of a fresh project is completed' do + it 'enqueues housekeeping when an import of a fresh project is completed' do project = create(:project_empty_repo, :import_started, import_type: :github) - project.import_state.finish + expect(Projects::AfterImportWorker).to receive(:perform_async).with(project.id) - expect(after_import_service).to have_received(:execute) - expect(housekeeping_service).to have_received(:execute) + project.import_state.finish end it 'does not perform housekeeping when project repository does not exist' do project = create(:project, :import_started, import_type: :github) - project.import_state.finish + expect(Projects::AfterImportWorker).not_to receive(:perform_async) - expect(housekeeping_service).not_to have_received(:execute) + project.import_state.finish end - it 'does not perform housekeeping when project does not have a valid import type' do + it 'does not qneueue housekeeping when project does not have a valid import type' do project = create(:project, :import_started, import_type: nil) - project.import_state.finish + expect(Projects::AfterImportWorker).not_to receive(:perform_async) - expect(housekeeping_service).not_to have_received(:execute) + project.import_state.finish end end end |