diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-04 00:09:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-04 00:09:57 +0300 |
commit | b8fcc8edb4a289ef3ef4fee0ed8fd88e853a2396 (patch) | |
tree | 31658d7760d36aa3b368e020e08f4d21c678f2e3 /spec/models | |
parent | d83bbccfcd07ddab93be73959e3b149b75831e28 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/factories_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/namespace_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/packages/rpm/repository_file_spec.rb | 44 | ||||
-rw-r--r-- | spec/models/pool_repository_spec.rb | 7 |
4 files changed, 62 insertions, 6 deletions
diff --git a/spec/models/factories_spec.rb b/spec/models/factories_spec.rb index 2993b2aee58..1874a74ad96 100644 --- a/spec/models/factories_spec.rb +++ b/spec/models/factories_spec.rb @@ -25,6 +25,7 @@ RSpec.describe 'factories' do [:issue_customer_relations_contact, :for_contact], [:issue_customer_relations_contact, :for_issue], [:package_file, :object_storage], + [:rpm_repository_file, :object_storage], [:pages_domain, :without_certificate], [:pages_domain, :without_key], [:pages_domain, :with_missing_chain], diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index a39a8d18207..7bf0491d11e 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1036,7 +1036,9 @@ RSpec.describe Namespace do let(:pages_dir) { File.join(TestEnv.pages_path) } def expect_project_directories_at(namespace_path, with_pages: true) - expected_repository_path = File.join(TestEnv.repos_path, namespace_path, 'the-project.git') + expected_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + File.join(TestEnv.repos_path, namespace_path, 'the-project.git') + end expected_upload_path = File.join(uploads_dir, namespace_path, 'the-project') expected_pages_path = File.join(pages_dir, namespace_path, 'the-project') @@ -1046,15 +1048,19 @@ RSpec.describe Namespace do end before do - FileUtils.mkdir_p(File.join(TestEnv.repos_path, "#{project.full_path}.git")) + Gitlab::GitalyClient::StorageSettings.allow_disk_access do + FileUtils.mkdir_p(File.join(TestEnv.repos_path, "#{project.full_path}.git")) + end FileUtils.mkdir_p(File.join(uploads_dir, project.full_path)) FileUtils.mkdir_p(File.join(pages_dir, project.full_path)) end after do - FileUtils.remove_entry(File.join(TestEnv.repos_path, parent.full_path), true) - FileUtils.remove_entry(File.join(TestEnv.repos_path, new_parent.full_path), true) - FileUtils.remove_entry(File.join(TestEnv.repos_path, child.full_path), true) + Gitlab::GitalyClient::StorageSettings.allow_disk_access do + FileUtils.remove_entry(File.join(TestEnv.repos_path, parent.full_path), true) + FileUtils.remove_entry(File.join(TestEnv.repos_path, new_parent.full_path), true) + FileUtils.remove_entry(File.join(TestEnv.repos_path, child.full_path), true) + end FileUtils.remove_entry(File.join(uploads_dir, project.full_path), true) FileUtils.remove_entry(pages_dir, true) end diff --git a/spec/models/packages/rpm/repository_file_spec.rb b/spec/models/packages/rpm/repository_file_spec.rb new file mode 100644 index 00000000000..34347793dd8 --- /dev/null +++ b/spec/models/packages/rpm/repository_file_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Packages::Rpm::RepositoryFile, type: :model do + using RSpec::Parameterized::TableSyntax + + let_it_be(:repository_file) { create(:rpm_repository_file) } + + it_behaves_like 'having unique enum values' + + describe 'relationships' do + it { is_expected.to belong_to(:project) } + end + + describe 'validations' do + it { is_expected.to validate_presence_of(:project) } + end + + context 'when updating project statistics' do + context 'when the package file has an explicit size' do + it_behaves_like 'UpdateProjectStatistics' do + subject { build(:rpm_repository_file, size: 42) } + end + end + + context 'when the package file does not have a size' do + it_behaves_like 'UpdateProjectStatistics' do + subject { build(:rpm_repository_file, size: nil) } + end + end + end + + context 'with status scopes' do + let_it_be(:pending_destruction_repository_package_file) do + create(:rpm_repository_file, :pending_destruction) + end + + describe '.with_status' do + subject { described_class.with_status(:pending_destruction) } + + it { is_expected.to contain_exactly(pending_destruction_repository_package_file) } + end + end +end diff --git a/spec/models/pool_repository_spec.rb b/spec/models/pool_repository_spec.rb index bf88e941540..c0eb770a414 100644 --- a/spec/models/pool_repository_spec.rb +++ b/spec/models/pool_repository_spec.rb @@ -26,9 +26,14 @@ RSpec.describe PoolRepository do describe '#unlink_repository' do let(:pool) { create(:pool_repository, :ready) } - let(:repository_path) { File.join(TestEnv.repos_path, pool.source_project.repository.relative_path) } let(:alternates_file) { File.join(repository_path, 'objects', 'info', 'alternates') } + let(:repository_path) do + Gitlab::GitalyClient::StorageSettings.allow_disk_access do + File.join(TestEnv.repos_path, pool.source_project.repository.relative_path) + end + end + before do pool.link_repository(pool.source_project.repository) end |