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

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

require 'spec_helper'

RSpec.describe Ci::PendingBuilds::UpdateGroupWorker, feature_category: :groups_and_projects do
  describe '#perform' do
    let(:worker) { described_class.new }

    context 'when a group is not provided' do
      it 'does not call the service' do
        expect(::Ci::UpdatePendingBuildService).not_to receive(:new)
      end
    end

    context 'when everything is ok' do
      let(:group) { create(:group) }
      let(:update_pending_build_service) { instance_double(::Ci::UpdatePendingBuildService) }
      let(:update_params) { { "namespace_id" => group.id } }

      it 'calls the service' do
        expect(::Ci::UpdatePendingBuildService).to receive(:new).with(group, update_params).and_return(update_pending_build_service)
        expect(update_pending_build_service).to receive(:execute)

        worker.perform(group.id, update_params)
      end

      include_examples 'an idempotent worker' do
        let(:pending_build) { create(:ci_pending_build) }
        let(:update_params) { { "namespace_id" => pending_build.namespace_id } }
        let(:job_args) { [pending_build.namespace_id, update_params] }

        it 'updates the pending builds' do
          subject

          expect(pending_build.reload.namespace_id).to eq(update_params["namespace_id"])
        end
      end
    end
  end
end