diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/models/packages/package_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/packages/package_spec.rb')
-rw-r--r-- | spec/models/packages/package_spec.rb | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb index 41a731b87e9..705a1991845 100644 --- a/spec/models/packages/package_spec.rb +++ b/spec/models/packages/package_spec.rb @@ -10,6 +10,8 @@ RSpec.describe Packages::Package, type: :model do it { is_expected.to have_many(:package_files).dependent(:destroy) } it { is_expected.to have_many(:dependency_links).inverse_of(:package) } it { is_expected.to have_many(:tags).inverse_of(:package) } + it { is_expected.to have_many(:build_infos).inverse_of(:package) } + it { is_expected.to have_many(:pipelines).through(:build_infos) } it { is_expected.to have_one(:conan_metadatum).inverse_of(:package) } it { is_expected.to have_one(:maven_metadatum).inverse_of(:package) } it { is_expected.to have_one(:nuget_metadatum).inverse_of(:package) } @@ -171,6 +173,13 @@ RSpec.describe Packages::Package, type: :model do it { is_expected.not_to allow_value('%2e%2e%2f1.2.3').for(:version) } end + context 'composer package' do + it_behaves_like 'validating version to be SemVer compliant for', :composer_package + + it { is_expected.to allow_value('dev-master').for(:version) } + it { is_expected.to allow_value('2.x-dev').for(:version) } + end + context 'maven package' do subject { build_stubbed(:maven_package) } @@ -573,7 +582,7 @@ RSpec.describe Packages::Package, type: :model do end describe '#pipeline' do - let_it_be(:package) { create(:maven_package) } + let_it_be_with_refind(:package) { create(:maven_package) } context 'package without pipeline' do it 'returns nil if there is no pipeline' do @@ -585,7 +594,7 @@ RSpec.describe Packages::Package, type: :model do let_it_be(:pipeline) { create(:ci_pipeline) } before do - package.create_build_info!(pipeline: pipeline) + package.build_infos.create!(pipeline: pipeline) end it 'returns the pipeline' do @@ -630,4 +639,23 @@ RSpec.describe Packages::Package, type: :model do end end end + + describe '#original_build_info' do + let_it_be_with_refind(:package) { create(:npm_package) } + + context 'without build_infos' do + it 'returns nil' do + expect(package.original_build_info).to be_nil + end + end + + context 'with build_infos' do + let_it_be(:first_build_info) { create(:package_build_info, :with_pipeline, package: package) } + let_it_be(:second_build_info) { create(:package_build_info, :with_pipeline, package: package) } + + it 'returns the first build info' do + expect(package.original_build_info).to eq(first_build_info) + end + end + end end |