summaryrefslogtreecommitdiff
path: root/spec/models/ci/resource_spec.rb
blob: 27e512e2c454b7811c0a90d434328b513c84a8d2 (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
# frozen_string_literal: true

require 'spec_helper'

describe Ci::Resource do
  describe '.free' do
    subject { described_class.free }

    let(:resource_group) { create(:ci_resource_group) }
    let!(:free_resource) { resource_group.resources.take }
    let!(:retained_resource) { create(:ci_resource, :retained, resource_group: resource_group) }

    it 'returns free resources' do
      is_expected.to eq([free_resource])
    end
  end

  describe '.retained_by' do
    subject { described_class.retained_by(build) }

    let(:build) { create(:ci_build) }
    let!(:resource) { create(:ci_resource, build: build) }

    it 'returns retained resources' do
      is_expected.to eq([resource])
    end
  end
end