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

background_transaction_spec.rb « metrics « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 640bbebf0daf6f5f21c618954d64a251fd8e6751 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Metrics::BackgroundTransaction do
  let(:test_worker_class) { double(:class, name: 'TestWorker') }

  subject { described_class.new(test_worker_class) }

  describe '#label' do
    it 'returns labels based on class name' do
      expect(subject.labels).to eq(controller: 'TestWorker', action: 'perform', feature_category: '')
    end

    it 'contains only the labels defined for metrics' do
      expect(subject.labels.keys).to contain_exactly(*described_class.superclass::BASE_LABELS.keys)
    end

    it 'includes the feature category if there is one' do
      expect(test_worker_class).to receive(:get_feature_category).and_return('source_code_management')
      expect(subject.labels).to include(feature_category: 'source_code_management')
    end
  end
end