diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/models/packages/package_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/models/packages/package_spec.rb')
-rw-r--r-- | spec/models/packages/package_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb index 4d4d4ad4fa9..99e5769fc1f 100644 --- a/spec/models/packages/package_spec.rb +++ b/spec/models/packages/package_spec.rb @@ -1165,4 +1165,47 @@ RSpec.describe Packages::Package, type: :model do it_behaves_like 'not enqueuing a sync worker job' end end + + describe '#create_build_infos!' do + let_it_be(:package) { create(:package) } + let_it_be(:pipeline) { create(:ci_pipeline) } + + let(:build) { double(pipeline: pipeline) } + + subject { package.create_build_infos!(build) } + + context 'with a valid build' do + it 'creates a build info' do + expect { subject }.to change { ::Packages::BuildInfo.count }.by(1) + + last_build = ::Packages::BuildInfo.last + expect(last_build.package).to eq(package) + expect(last_build.pipeline).to eq(pipeline) + end + + context 'with an already existing build info' do + let_it_be(:build_info) { create(:packages_build_info, package: package, pipeline: pipeline) } + + it 'does not create a build info' do + expect { subject }.not_to change { ::Packages::BuildInfo.count } + end + end + end + + context 'with a nil build' do + let(:build) { nil } + + it 'does not create a build info' do + expect { subject }.not_to change { ::Packages::BuildInfo.count } + end + end + + context 'with a build without a pipeline' do + let(:build) { double(pipeline: nil) } + + it 'does not create a build info' do + expect { subject }.not_to change { ::Packages::BuildInfo.count } + end + end + end end |