diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-18 03:07:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-18 03:07:45 +0300 |
commit | 7c077d960393e14b56d43cceaa7f609c703ac55f (patch) | |
tree | c3a5d79554b9be1d7434c8e9a8fcae35ab64af32 /spec/lib/gitlab/tracking | |
parent | da35510cdad8f8d3cb6c119682dc2735531983cd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/tracking')
-rw-r--r-- | spec/lib/gitlab/tracking/incident_management_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/spec/lib/gitlab/tracking/incident_management_spec.rb b/spec/lib/gitlab/tracking/incident_management_spec.rb new file mode 100644 index 00000000000..6f7e04b7c16 --- /dev/null +++ b/spec/lib/gitlab/tracking/incident_management_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Tracking::IncidentManagement do + describe '.track_from_params' do + shared_examples 'a tracked event' do |label, value = nil| + it 'creates the tracking event with the correct details' do + expect(::Gitlab::Tracking) + .to receive(:event) + .with( + 'IncidentManagement::Settings', + label, + value || kind_of(Hash) + ) + end + end + + after do + described_class.track_from_params(params) + end + + context 'known params' do + known_params = described_class.tracking_keys + + known_params.each do |key, values| + context "param #{key}" do + let(:params) { { key => '1' } } + + it_behaves_like 'a tracked event', "enabled_#{known_params[key][:name]}" + end + end + + context 'different input values' do + shared_examples 'the correct prefixed event name' do |input, enabled| + let(:params) { { issue_template_key: input } } + + it 'matches' do + expect(::Gitlab::Tracking) + .to receive(:event) + .with( + anything, + "#{enabled}_issue_template_on_alerts", + anything + ) + end + end + + it_behaves_like 'the correct prefixed event name', 1, 'enabled' + it_behaves_like 'the correct prefixed event name', '1', 'enabled' + it_behaves_like 'the correct prefixed event name', 'template', 'enabled' + it_behaves_like 'the correct prefixed event name', '', 'disabled' + it_behaves_like 'the correct prefixed event name', nil, 'disabled' + end + + context 'param with label' do + let(:params) { { issue_template_key: '1' } } + + it_behaves_like 'a tracked event', "enabled_issue_template_on_alerts", { label: 'Template name', property: '1' } + end + + context 'param without label' do + let(:params) { { create_issue: '1' } } + + it_behaves_like 'a tracked event', "enabled_issue_auto_creation_on_alerts", {} + end + end + + context 'unknown params' do + let(:params) { { 'unknown' => '1' } } + + it 'does not create the tracking event' do + expect(::Gitlab::Tracking) + .not_to receive(:event) + end + end + end +end |