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

repository_file_spec.rb « rpm « packages « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1147fd66ac65f1a31c8b4c7db24c612619b738f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# frozen_string_literal: true
require 'spec_helper'

RSpec.describe Packages::Rpm::RepositoryFile, type: :model, feature_category: :package_registry 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

  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

  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