2019-07-29 09:58:58 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 18:09:03 +00:00
|
|
|
RSpec.describe Gitlab::UsageDataCounters::SearchCounter, :clean_gitlab_redis_shared_state do
|
2020-05-25 06:08:38 +00:00
|
|
|
shared_examples_for 'usage counter with totals' do |counter|
|
|
|
|
it 'increments counter and returns total count' do
|
|
|
|
expect(described_class.read(counter)).to eq(0)
|
2019-07-29 09:58:58 +00:00
|
|
|
|
2020-05-25 06:08:38 +00:00
|
|
|
2.times { described_class.count(counter) }
|
2019-07-29 09:58:58 +00:00
|
|
|
|
2020-05-25 06:08:38 +00:00
|
|
|
expect(described_class.read(counter)).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'all_searches counter' do
|
|
|
|
it_behaves_like 'usage counter with totals', :all_searches
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'navbar_searches counter' do
|
|
|
|
it_behaves_like 'usage counter with totals', :navbar_searches
|
2019-07-29 09:58:58 +00:00
|
|
|
end
|
2020-11-19 15:09:13 +00:00
|
|
|
|
|
|
|
describe '.fetch_supported_event' do
|
|
|
|
subject { described_class.fetch_supported_event(event_name) }
|
|
|
|
|
|
|
|
let(:event_name) { 'all_searches' }
|
|
|
|
|
|
|
|
it { is_expected.to eq 'all_searches' }
|
|
|
|
end
|
2019-07-29 09:58:58 +00:00
|
|
|
end
|