summaryrefslogtreecommitdiff
path: root/spec/workers/analytics/instance_statistics/count_job_trigger_worker_spec.rb
blob: 620900b3402848f7cc3a22287c49ef3ce8d8b389 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Analytics::InstanceStatistics::CountJobTriggerWorker do
  it_behaves_like 'an idempotent worker'

  context 'triggers a job for each measurement identifiers' do
    let(:expected_count) { Analytics::InstanceStatistics::Measurement.identifiers.size }

    it 'triggers CounterJobWorker jobs' do
      subject.perform

      expect(Analytics::InstanceStatistics::CounterJobWorker.jobs.count).to eq(expected_count)
    end
  end

  context 'when the `store_instance_statistics_measurements` feature flag is off' do
    before do
      stub_feature_flags(store_instance_statistics_measurements: false)
    end

    it 'does not trigger any CounterJobWorker job' do
      subject.perform

      expect(Analytics::InstanceStatistics::CounterJobWorker.jobs.count).to eq(0)
    end
  end
end