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

template_usage_spec.rb « chain « pipeline « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3616461d94f254fd9db0349c10d74912011e2a48 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Pipeline::Chain::TemplateUsage do
  let_it_be(:project) { create(:project) }
  let_it_be(:user) { create(:user) }
  let(:pipeline) { create(:ci_pipeline, project: project) }

  let(:command) do
    Gitlab::Ci::Pipeline::Chain::Command.new(project: project, current_user: user)
  end

  let(:step) { described_class.new(pipeline, command) }

  describe '#perform!' do
    subject(:perform) { step.perform! }

    it 'tracks the included templates' do
      expect(command).to(
        receive(:yaml_processor_result)
          .and_return(
            double(included_templates: %w(Template-1 Template-2))
          )
      )

      %w(Template-1 Template-2).each do |expected_template|
        expect(Gitlab::UsageDataCounters::CiTemplateUniqueCounter).to(
          receive(:track_unique_project_event)
            .with(project_id: project.id, template: expected_template)
        )
      end

      perform
    end
  end
end