diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/models/packages | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/packages')
-rw-r--r-- | spec/models/packages/build_info_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/packages/package_file_build_info_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/packages/package_file_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/packages/package_spec.rb | 32 |
4 files changed, 50 insertions, 2 deletions
diff --git a/spec/models/packages/build_info_spec.rb b/spec/models/packages/build_info_spec.rb new file mode 100644 index 00000000000..a4369c56fe2 --- /dev/null +++ b/spec/models/packages/build_info_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Packages::BuildInfo, type: :model do + describe 'relationships' do + it { is_expected.to belong_to(:package) } + it { is_expected.to belong_to(:pipeline) } + end +end diff --git a/spec/models/packages/package_file_build_info_spec.rb b/spec/models/packages/package_file_build_info_spec.rb new file mode 100644 index 00000000000..18d6e720bf8 --- /dev/null +++ b/spec/models/packages/package_file_build_info_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Packages::PackageFileBuildInfo, type: :model do + describe 'relationships' do + it { is_expected.to belong_to(:package_file) } + it { is_expected.to belong_to(:pipeline) } + end +end diff --git a/spec/models/packages/package_file_spec.rb b/spec/models/packages/package_file_spec.rb index 6b992dbc2a5..ef09fb037e9 100644 --- a/spec/models/packages/package_file_spec.rb +++ b/spec/models/packages/package_file_spec.rb @@ -5,6 +5,8 @@ RSpec.describe Packages::PackageFile, type: :model do describe 'relationships' do it { is_expected.to belong_to(:package) } it { is_expected.to have_one(:conan_file_metadatum) } + it { is_expected.to have_many(:package_file_build_infos).inverse_of(:package_file) } + it { is_expected.to have_many(:pipelines).through(:package_file_build_infos) } end describe 'validations' do 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 |