diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/services/packages/composer/create_package_service_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/services/packages/composer/create_package_service_spec.rb')
-rw-r--r-- | spec/services/packages/composer/create_package_service_spec.rb | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/spec/services/packages/composer/create_package_service_spec.rb b/spec/services/packages/composer/create_package_service_spec.rb index 553d58fdd86..2ffd0a269f2 100644 --- a/spec/services/packages/composer/create_package_service_spec.rb +++ b/spec/services/packages/composer/create_package_service_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Packages::Composer::CreatePackageService do let_it_be(:package_name) { 'composer-package-name' } let_it_be(:json) { { name: package_name }.to_json } - let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json } ) } + let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json }) } let_it_be(:user) { create(:user) } let(:params) do @@ -24,13 +24,30 @@ RSpec.describe Packages::Composer::CreatePackageService do let(:created_package) { Packages::Package.composer.last } + shared_examples 'using the cache update worker' do + context 'with remove_composer_v1_cache_code enabled' do + it 'does not enqueue a cache update job' do + expect(::Packages::Composer::CacheUpdateWorker).not_to receive(:perform_async) + + subject + end + end + + context 'with remove_composer_v1_cache_code disabled' do + it 'enqueues a cache update job' do + stub_feature_flags(remove_composer_v1_cache_code: true) + expect(::Packages::Composer::CacheUpdateWorker).not_to receive(:perform_async) + + subject + end + end + end + context 'without an existing package' do context 'with a branch' do let(:branch) { project.repository.find_branch('master') } it 'creates the package' do - expect(::Packages::Composer::CacheUpdateWorker).to receive(:perform_async).with(project.id, package_name, nil) - expect { subject } .to change { Packages::Package.composer.count }.by(1) .and change { Packages::Composer::Metadatum.count }.by(1) @@ -47,6 +64,7 @@ RSpec.describe Packages::Composer::CreatePackageService do it_behaves_like 'assigns build to package' it_behaves_like 'assigns status to package' + it_behaves_like 'using the cache update worker' end context 'with a tag' do @@ -57,8 +75,6 @@ RSpec.describe Packages::Composer::CreatePackageService do end it 'creates the package' do - expect(::Packages::Composer::CacheUpdateWorker).to receive(:perform_async).with(project.id, package_name, nil) - expect { subject } .to change { Packages::Package.composer.count }.by(1) .and change { Packages::Composer::Metadatum.count }.by(1) @@ -73,6 +89,7 @@ RSpec.describe Packages::Composer::CreatePackageService do it_behaves_like 'assigns build to package' it_behaves_like 'assigns status to package' + it_behaves_like 'using the cache update worker' end end @@ -85,12 +102,12 @@ RSpec.describe Packages::Composer::CreatePackageService do end it 'does not create a new package' do - expect(::Packages::Composer::CacheUpdateWorker).to receive(:perform_async).with(project.id, package_name, nil) - expect { subject } .to change { Packages::Package.composer.count }.by(0) .and change { Packages::Composer::Metadatum.count }.by(0) end + + it_behaves_like 'using the cache update worker' end context 'belonging to another project' do @@ -108,12 +125,12 @@ RSpec.describe Packages::Composer::CreatePackageService do let!(:other_package) { create(:package, name: package_name, version: 'dev-master', project: other_project) } it 'creates the package' do - expect(::Packages::Composer::CacheUpdateWorker).to receive(:perform_async).with(project.id, package_name, nil) - expect { subject } .to change { Packages::Package.composer.count }.by(1) .and change { Packages::Composer::Metadatum.count }.by(1) end + + it_behaves_like 'using the cache update worker' end end end |