Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /spec/models/packages/package_file_spec.rb
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/models/packages/package_file_spec.rb')
-rw-r--r--spec/models/packages/package_file_spec.rb47
1 files changed, 43 insertions, 4 deletions
diff --git a/spec/models/packages/package_file_spec.rb b/spec/models/packages/package_file_spec.rb
index 9cf998a0639..f8ddd59ddc8 100644
--- a/spec/models/packages/package_file_spec.rb
+++ b/spec/models/packages/package_file_spec.rb
@@ -2,12 +2,18 @@
require 'spec_helper'
RSpec.describe Packages::PackageFile, type: :model do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:package_file1) { create(:package_file, :xml, file_name: 'FooBar') }
+ let_it_be(:package_file2) { create(:package_file, :xml, file_name: 'ThisIsATest') }
+ let_it_be(:debian_package) { create(:debian_package, project: project) }
+
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) }
it { is_expected.to have_one(:debian_file_metadatum).inverse_of(:package_file).class_name('Packages::Debian::FileMetadatum') }
+ it { is_expected.to have_one(:helm_file_metadatum).inverse_of(:package_file).class_name('Packages::Helm::FileMetadatum') }
end
describe 'validations' do
@@ -15,9 +21,6 @@ RSpec.describe Packages::PackageFile, type: :model do
end
context 'with package filenames' do
- let_it_be(:package_file1) { create(:package_file, :xml, file_name: 'FooBar') }
- let_it_be(:package_file2) { create(:package_file, :xml, file_name: 'ThisIsATest') }
-
describe '.with_file_name' do
let(:filename) { 'FooBar' }
@@ -51,6 +54,13 @@ RSpec.describe Packages::PackageFile, type: :model do
end
end
+ describe '.for_package_ids' do
+ it 'returns matching packages' do
+ expect(described_class.for_package_ids([package_file1.package.id, package_file2.package.id]))
+ .to contain_exactly(package_file1, package_file2)
+ end
+ end
+
describe '.with_conan_package_reference' do
let_it_be(:non_matching_package_file) { create(:package_file, :nuget) }
let_it_be(:metadatum) { create(:conan_file_metadatum, :package_file) }
@@ -63,7 +73,6 @@ RSpec.describe Packages::PackageFile, type: :model do
end
describe '.for_rubygem_with_file_name' do
- let_it_be(:project) { create(:project) }
let_it_be(:non_ruby_package) { create(:nuget_package, project: project, package_type: :nuget) }
let_it_be(:ruby_package) { create(:rubygems_package, project: project, package_type: :rubygems) }
let_it_be(:file_name) { 'other.gem' }
@@ -77,6 +86,36 @@ RSpec.describe Packages::PackageFile, type: :model do
end
end
+ context 'Debian scopes' do
+ let_it_be(:debian_changes) { debian_package.package_files.last }
+ let_it_be(:debian_deb) { create(:debian_package_file, package: debian_package)}
+ let_it_be(:debian_udeb) { create(:debian_package_file, :udeb, package: debian_package)}
+
+ let_it_be(:debian_contrib) do
+ create(:debian_package_file, package: debian_package).tap do |pf|
+ pf.debian_file_metadatum.update!(component: 'contrib')
+ end
+ end
+
+ let_it_be(:debian_mipsel) do
+ create(:debian_package_file, package: debian_package).tap do |pf|
+ pf.debian_file_metadatum.update!(architecture: 'mipsel')
+ end
+ end
+
+ describe '#with_debian_file_type' do
+ it { expect(described_class.with_debian_file_type(:changes)).to contain_exactly(debian_changes) }
+ end
+
+ describe '#with_debian_component_name' do
+ it { expect(described_class.with_debian_component_name('contrib')).to contain_exactly(debian_contrib) }
+ end
+
+ describe '#with_debian_architecture_name' do
+ it { expect(described_class.with_debian_architecture_name('mipsel')).to contain_exactly(debian_mipsel) }
+ end
+ end
+
describe '#update_file_store callback' do
let_it_be(:package_file) { build(:package_file, :nuget, size: nil) }