diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 12:09:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 12:09:13 +0000 |
commit | 211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7 (patch) | |
tree | 0ad37172721a39b0d57240bb1b4e70f200a0d93e /spec/workers | |
parent | 456a7247f9e88fc2518b69a1a00e905c6db6d775 (diff) | |
download | gitlab-ce-211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/propagate_instance_level_service_worker_spec.rb | 31 | ||||
-rw-r--r-- | spec/workers/propagate_service_template_worker_spec.rb | 31 | ||||
-rw-r--r-- | spec/workers/repository_fork_worker_spec.rb | 24 |
3 files changed, 53 insertions, 33 deletions
diff --git a/spec/workers/propagate_instance_level_service_worker_spec.rb b/spec/workers/propagate_instance_level_service_worker_spec.rb new file mode 100644 index 00000000000..6552b198181 --- /dev/null +++ b/spec/workers/propagate_instance_level_service_worker_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe PropagateInstanceLevelServiceWorker do + include ExclusiveLeaseHelpers + + describe '#perform' do + it 'calls the propagate service with the instance level service' do + instance_level_service = PushoverService.create( + instance: true, + active: true, + properties: { + device: 'MyDevice', + sound: 'mic', + priority: 4, + user_key: 'asdf', + api_key: '123456789' + }) + + stub_exclusive_lease("propagate_instance_level_service_worker:#{instance_level_service.id}", + timeout: PropagateInstanceLevelServiceWorker::LEASE_TIMEOUT) + + expect(Projects::PropagateInstanceLevelService) + .to receive(:propagate) + .with(instance_level_service) + + subject.perform(instance_level_service.id) + end + end +end diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb deleted file mode 100644 index fb4ced77832..00000000000 --- a/spec/workers/propagate_service_template_worker_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe PropagateServiceTemplateWorker do - include ExclusiveLeaseHelpers - - describe '#perform' do - it 'calls the propagate service with the template' do - template = PushoverService.create( - template: true, - active: true, - properties: { - device: 'MyDevice', - sound: 'mic', - priority: 4, - user_key: 'asdf', - api_key: '123456789' - }) - - stub_exclusive_lease("propagate_service_template_worker:#{template.id}", - timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT) - - expect(Projects::PropagateServiceTemplate) - .to receive(:propagate) - .with(template) - - subject.perform(template.id) - end - end -end diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 26fd67adfaa..01104049404 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -72,13 +72,33 @@ describe RepositoryForkWorker do perform! end - it "handles bad fork" do - error_message = "Unable to fork project #{forked_project.id} for repository #{project.disk_path} -> #{forked_project.disk_path}" + it 'handles bad fork' do + error_message = "Unable to fork project #{forked_project.id} for repository #{project.disk_path} -> #{forked_project.disk_path}: Failed to create fork repository" expect_fork_repository.and_return(false) expect { perform! }.to raise_error(StandardError, error_message) end + + it 'calls Projects::LfsPointers::LfsLinkService#execute with OIDs of source project LFS objects' do + expect_fork_repository.and_return(true) + expect_next_instance_of(Projects::LfsPointers::LfsLinkService) do |service| + expect(service).to receive(:execute).with(project.lfs_objects_oids) + end + + perform! + end + + it "handles LFS objects link failure" do + error_message = "Unable to fork project #{forked_project.id} for repository #{project.disk_path} -> #{forked_project.disk_path}: Source project has too many LFS objects" + + expect_fork_repository.and_return(true) + expect_next_instance_of(Projects::LfsPointers::LfsLinkService) do |service| + expect(service).to receive(:execute).and_raise(Projects::LfsPointers::LfsLinkService::TooManyOidsError) + end + + expect { perform! }.to raise_error(StandardError, error_message) + end end context 'only project ID passed' do |