diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/product_analytics | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/product_analytics')
-rw-r--r-- | spec/lib/product_analytics/event_params_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/lib/product_analytics/event_params_spec.rb b/spec/lib/product_analytics/event_params_spec.rb new file mode 100644 index 00000000000..d6c098599d6 --- /dev/null +++ b/spec/lib/product_analytics/event_params_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ProductAnalytics::EventParams do + describe '.parse_event_params' do + subject { described_class.parse_event_params(raw_event) } + + let(:raw_event) { Gitlab::Json.parse(fixture_file('product_analytics/event.json')) } + + it 'extracts all params from raw event' do + expected_params = { + project_id: '1', + platform: 'web', + name_tracker: 'sp', + v_tracker: 'js-2.14.0', + event_id: 'fbf14096-74ee-47e4-883c-8a0d6cb72e37', + domain_userid: '79543c31-cfc3-4479-a737-fafb9333c8ba', + domain_sessionid: '54f6d3f3-f4f9-4fdc-87e0-a2c775234c1b', + domain_sessionidx: 4, + page_url: 'http://example.com/products/1', + page_referrer: 'http://example.com/products/1', + br_lang: 'en-US', + br_cookies: true, + os_timezone: 'America/Los_Angeles', + doc_charset: 'UTF-8' + } + + expect(subject).to include(expected_params) + end + end + + describe '.has_required_params?' do + subject { described_class.has_required_params?(params) } + + context 'aid and eid are present' do + let(:params) { { 'aid' => 1, 'eid' => 2 } } + + it { expect(subject).to be_truthy } + end + + context 'aid and eid are missing' do + let(:params) { {} } + + it { expect(subject).to be_falsey } + end + + context 'eid is missing' do + let(:params) { { 'aid' => 1 } } + + it { expect(subject).to be_falsey } + end + end +end |