diff options
Diffstat (limited to 'spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb index d4148b57348..4996b0a0089 100644 --- a/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb @@ -77,11 +77,22 @@ RSpec.describe Gitlab::UsageDataCounters::CiTemplateUniqueCounter do let(:project_id) { 1 } let(:config_source) { :repository_source } - Dir.glob(File.join('lib', 'gitlab', 'ci', 'templates', '**'), base: Rails.root) do |template| + described_class.ci_templates.each do |template| next if described_class::TEMPLATE_TO_EVENT.key?(template) - it "does not track #{template}" do - expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to(receive(:track_event)) + it "has an event defined for #{template}" do + expect do + described_class.track_unique_project_event( + project_id: project_id, + template: template, + config_source: config_source + ) + end.not_to raise_error + end + + it "tracks #{template}" do + expected_template_event_name = described_class.ci_template_event_name(template, :repository_source) + expect(Gitlab::UsageDataCounters::HLLRedisCounter).to(receive(:track_event)).with(expected_template_event_name, values: project_id) described_class.track_unique_project_event(project_id: project_id, template: template, config_source: config_source) end |