blob: 4a31191d75f6de0caaa83c5fed00bad2c2fe1624 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::BaseCounter do
describe '.fetch_supported_event' do
subject { described_class.fetch_supported_event(event_name) }
let(:event_name) { 'generic_event' }
let(:prefix) { 'generic' }
let(:known_events) { %w[event another_event] }
before do
allow(described_class).to receive(:prefix) { prefix }
allow(described_class).to receive(:known_events) { known_events }
end
it 'returns the matching event' do
is_expected.to eq 'event'
end
context 'when event is unknown' do
let(:event_name) { 'generic_unknown_event' }
it { is_expected.to be_nil }
end
context 'when prefix does not match the event name' do
let(:prefix) { 'special' }
it { is_expected.to be_nil }
end
end
end
|