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

unlock_previous_pipelines_worker_spec.rb « refs « ci « workers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2f00ea45edc5e11aa9d5453ca0332778efe47b5b (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::Refs::UnlockPreviousPipelinesWorker, :unlock_pipelines, :clean_gitlab_redis_shared_state, feature_category: :build_artifacts do
  let(:worker) { described_class.new }

  let!(:older_pipeline) do
    create(
      :ci_pipeline,
      :with_persisted_artifacts,
      :artifacts_locked
    )
  end

  let!(:pipeline) do
    create(
      :ci_pipeline,
      :with_persisted_artifacts,
      ref: older_pipeline.ref,
      tag: older_pipeline.tag,
      project: older_pipeline.project
    )
  end

  describe '#perform' do
    it 'executes a service' do
      expect_next_instance_of(Ci::Refs::EnqueuePipelinesToUnlockService) do |instance|
        expect(instance).to receive(:execute).and_call_original
      end

      worker.perform(pipeline.ci_ref.id)
    end
  end

  it_behaves_like 'an idempotent worker' do
    let(:job_args) { pipeline.ci_ref.id }

    it 'only enqueues IDs of older pipelines if they are not in the queue' do
      expect { subject }
        .to change { pipeline_ids_waiting_to_be_unlocked }
        .from([])
        .to([older_pipeline.id])
    end
  end
end