diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/services/event_create_service_spec.rb | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/services/event_create_service_spec.rb')
-rw-r--r-- | spec/services/event_create_service_spec.rb | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb index 56da85cc4a0..e66b413a5c9 100644 --- a/spec/services/event_create_service_spec.rb +++ b/spec/services/event_create_service_spec.rb @@ -379,10 +379,14 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi end end - describe 'design events' do + describe 'design events', :snowplow do let_it_be(:design) { create(:design, project: project) } let_it_be(:author) { user } + before do + allow(Gitlab::Tracking).to receive(:event) # rubocop:disable RSpec/ExpectGitlabTracking + end + describe '#save_designs' do let_it_be(:updated) { create_list(:design, 5) } let_it_be(:created) { create_list(:design, 3) } @@ -411,6 +415,44 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi it_behaves_like "it records the event in the event counter" do let(:event_action) { Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION } end + + it 'records correct create payload with Snowplow event' do + service.save_designs(author, create: [design]) + + expect_snowplow_event( + category: Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION.to_s, + action: 'create', + namespace: design.project.namespace, + user: author, + project: design.project, + label: 'design_users' + ) + end + + it 'records correct update payload with Snowplow event' do + service.save_designs(author, update: [design]) + + expect_snowplow_event( + category: Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION.to_s, + action: 'update', + namespace: design.project.namespace, + user: author, + project: design.project, + label: 'design_users' + ) + end + + context 'when FF is disabled' do + before do + stub_feature_flags(route_hll_to_snowplow_phase2: false) + end + + it 'doesnt emit snowwplow events', :snowplow do + subject + + expect_no_snowplow_event + end + end end describe '#destroy_designs' do @@ -434,6 +476,31 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi it_behaves_like "it records the event in the event counter" do let(:event_action) { Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION } end + + it 'records correct payload with Snowplow event' do + service.destroy_designs([design], author) + + expect_snowplow_event( + category: Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION.to_s, + action: 'destroy', + namespace: design.project.namespace, + user: author, + project: design.project, + label: 'design_users' + ) + end + + context 'when FF is disabled' do + before do + stub_feature_flags(route_hll_to_snowplow_phase2: false) + end + + it 'doesnt emit snowwplow events', :snowplow do + subject + + expect_no_snowplow_event + end + end end end |