diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/lib/gitlab/tracking_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/lib/gitlab/tracking_spec.rb')
-rw-r--r-- | spec/lib/gitlab/tracking_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/lib/gitlab/tracking_spec.rb b/spec/lib/gitlab/tracking_spec.rb index cd83971aef9..cc973be8be9 100644 --- a/spec/lib/gitlab/tracking_spec.rb +++ b/spec/lib/gitlab/tracking_spec.rb @@ -149,4 +149,42 @@ RSpec.describe Gitlab::Tracking do described_class.event(nil, 'some_action') end end + + describe '.definition' do + let(:namespace) { create(:namespace) } + + let_it_be(:definition_action) { 'definition_action' } + let_it_be(:definition_category) { 'definition_category' } + let_it_be(:label_description) { 'definition label description' } + let_it_be(:test_definition) {{ 'category': definition_category, 'action': definition_action }} + + before do + allow_next_instance_of(described_class) do |instance| + allow(instance).to receive(:event) + end + allow_next_instance_of(Gitlab::Tracking::Destinations::Snowplow) do |instance| + allow(instance).to receive(:event) + end + allow(YAML).to receive(:load_file).with(Rails.root.join('config/events/filename.yml')).and_return(test_definition) + end + + it 'dispatchs the data to .event' do + project = build_stubbed(:project) + user = build_stubbed(:user) + + expect(described_class).to receive(:event) do |category, action, args| + expect(category).to eq(definition_category) + expect(action).to eq(definition_action) + expect(args[:label]).to eq('label') + expect(args[:property]).to eq('...') + expect(args[:project]).to eq(project) + expect(args[:user]).to eq(user) + expect(args[:namespace]).to eq(namespace) + expect(args[:extra_key_1]).to eq('extra value 1') + end + + described_class.definition('filename', category: nil, action: nil, label: 'label', property: '...', + project: project, user: user, namespace: namespace, extra_key_1: 'extra value 1') + end + end end |