summaryrefslogtreecommitdiff
path: root/spec/finders/artifacts_finder_spec.rb
blob: b956e2c95155a0d9f9db03a835866114ff8180f2 (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
# frozen_string_literal: true

require 'spec_helper'

describe ArtifactsFinder do
  let(:project) { create(:project) }

  describe '#execute' do
    before do
      create(:ci_build, :artifacts, project: project)
    end

    subject { described_class.new(project, params).execute }

    context 'with empty params' do
      let(:params) { {} }

      it 'returns all artifacts belonging to the project' do
        expect(subject).to contain_exactly(*project.job_artifacts)
      end
    end

    context 'with sort param' do
      let(:params) { { sort: 'size_desc' } }

      it 'sorts the artifacts' do
        expect(subject).to eq(project.job_artifacts.order_by('size_desc'))
      end
    end
  end
end