debian-mirror-gitlab/spec/models/packages/rpm/repository_file_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.9 KiB
Ruby
Raw Normal View History

2022-11-25 23:54:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe Packages::Rpm::RepositoryFile, type: :model, feature_category: :package_registry do
2022-11-25 23:54:43 +05:30
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
2023-03-04 22:38:38 +05:30
describe '.has_oversized_filelists?' do
let_it_be(:filelists) { create(:rpm_repository_file, :filelists, size: 21.megabytes) }
subject { described_class.has_oversized_filelists?(project_id: filelists.project_id) }
context 'when has oversized filelists' do
it { expect(subject).to be true }
end
context 'when filelists.xml is not oversized' do
before do
filelists.update!(size: 19.megabytes)
end
it { expect(subject).to be_falsey }
end
context 'when there is no filelists.xml' do
before do
filelists.destroy!
end
it { expect(subject).to be_falsey }
end
end
2022-11-25 23:54:43 +05:30
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