summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
blob: b5e32d1875f15f7057476d054eb9165c1a166683 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::UsageDataCounters::WebIdeCounter, :clean_gitlab_redis_shared_state do
  shared_examples 'counter examples' do
    it 'increments counter and return the total count' do
      expect(described_class.public_send(total_counter_method)).to eq(0)

      2.times { described_class.public_send(increment_counter_method) }

      expect(described_class.public_send(total_counter_method)).to eq(2)
    end
  end

  describe 'commits counter' do
    let(:increment_counter_method) { :increment_commits_count }
    let(:total_counter_method) { :total_commits_count }

    it_behaves_like 'counter examples'
  end

  describe 'merge requests counter' do
    let(:increment_counter_method) { :increment_merge_requests_count }
    let(:total_counter_method) { :total_merge_requests_count }

    it_behaves_like 'counter examples'
  end

  describe 'views counter' do
    let(:increment_counter_method) { :increment_views_count }
    let(:total_counter_method) { :total_views_count }

    it_behaves_like 'counter examples'
  end
end