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

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

require 'fast_spec_helper'

RSpec.describe Gitlab::UsageDataCounters do
  describe '.usage_data_counters' do
    subject { described_class.counters }

    it { is_expected.to all(respond_to :totals) }
    it { is_expected.to all(respond_to :fallback_totals) }
  end

  describe '.count' do
    subject { described_class.count(event_name) }

    let(:event_name) { 'web_ide_views' }

    it 'increases a view counter' do
      expect(Gitlab::UsageDataCounters::WebIdeCounter).to receive(:count).with('views')

      subject
    end

    context 'when event_name is not defined' do
      let(:event_name) { 'unknown' }

      it 'raises an exception' do
        expect { subject }.to raise_error(Gitlab::UsageDataCounters::UnknownEvent)
      end
    end
  end
end