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

incident_management_activity_shared_examples.rb « usage_data_counters « gitlab « lib « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88bc8e8d0c13c199a4051334b77819c1a2d0fd04 (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

RSpec.shared_examples 'an incident management tracked event' do |event|
  describe ".track_event", :clean_gitlab_redis_shared_state do
    let(:counter) { Gitlab::UsageDataCounters::HLLRedisCounter }
    let(:start_time) { 1.week.ago }
    let(:end_time) { 1.week.from_now }

    it "tracks the event using redis" do
      # Allow other subsequent calls
      allow(Gitlab::UsageDataCounters::HLLRedisCounter)
        .to receive(:track_event)

      expect(Gitlab::UsageDataCounters::HLLRedisCounter)
        .to receive(:track_event)
        .with(event.to_s, values: current_user.id)
        .and_call_original

      expect { subject }
        .to change { counter.unique_events(event_names: event.to_s, start_date: start_time, end_date: end_time) }
        .by 1
    end
  end
end

RSpec.shared_examples 'does not track incident management event' do |event|
  it 'does not track the event', :clean_gitlab_redis_shared_state do
    expect(Gitlab::UsageDataCounters::HLLRedisCounter)
      .not_to receive(:track_event)
      .with(anything, event.to_s)
  end
end