Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
deff21af
Commit
deff21af
authored
Oct 14, 2020
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use snowplow test helper
Instead of mocking Gitlab::Tracking
parent
f422a13f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
58 deletions
+59
-58
.rubocop_todo.yml
.rubocop_todo.yml
+0
-10
ee/spec/controllers/groups/analytics/coverage_reports_controller_spec.rb
...lers/groups/analytics/coverage_reports_controller_spec.rb
+6
-6
ee/spec/controllers/registrations_controller_spec.rb
ee/spec/controllers/registrations_controller_spec.rb
+12
-12
ee/spec/requests/api/visual_review_discussions_spec.rb
ee/spec/requests/api/visual_review_discussions_spec.rb
+3
-2
spec/controllers/groups_controller_spec.rb
spec/controllers/groups_controller_spec.rb
+15
-15
spec/services/clusters/applications/check_installation_progress_service_spec.rb
.../applications/check_installation_progress_service_spec.rb
+3
-3
spec/services/issues/zoom_link_service_spec.rb
spec/services/issues/zoom_link_service_spec.rb
+16
-6
spec/support/helpers/snowplow_helpers.rb
spec/support/helpers/snowplow_helpers.rb
+3
-3
spec/support/snowplow.rb
spec/support/snowplow.rb
+1
-1
No files found.
.rubocop_todo.yml
View file @
deff21af
...
...
@@ -186,31 +186,21 @@ RSpec/ExpectChange:
# Offense count: 47
RSpec/ExpectGitlabTracking
:
Exclude
:
-
'
ee/spec/controllers/groups/analytics/coverage_reports_controller_spec.rb'
-
'
ee/spec/controllers/projects/settings/operations_controller_spec.rb'
-
'
ee/spec/controllers/registrations_controller_spec.rb'
-
'
ee/spec/requests/api/visual_review_discussions_spec.rb'
-
'
ee/spec/services/epics/issue_promote_service_spec.rb'
-
'
spec/controllers/groups/registry/repositories_controller_spec.rb'
-
'
spec/controllers/groups_controller_spec.rb'
-
'
spec/controllers/projects/registry/repositories_controller_spec.rb'
-
'
spec/controllers/projects/registry/tags_controller_spec.rb'
-
'
spec/controllers/projects/settings/operations_controller_spec.rb'
-
'
spec/controllers/registrations_controller_spec.rb'
-
'
spec/lib/api/helpers_spec.rb'
-
'
spec/lib/gitlab/experimentation_spec.rb'
-
'
spec/mailers/notify_spec.rb'
-
'
spec/models/project_services/prometheus_service_spec.rb'
-
'
spec/requests/api/project_container_repositories_spec.rb'
-
'
spec/services/clusters/applications/check_installation_progress_service_spec.rb'
-
'
spec/services/issues/zoom_link_service_spec.rb'
-
'
spec/support/helpers/snowplow_helpers.rb'
-
'
spec/support/shared_examples/controllers/trackable_shared_examples.rb'
-
'
spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb'
-
'
spec/support/shared_examples/requests/api/discussions_shared_examples.rb'
-
'
spec/support/shared_examples/requests/api/packages_shared_examples.rb'
-
'
spec/support/shared_examples/requests/api/tracking_shared_examples.rb'
-
'
spec/support/snowplow.rb'
# Offense count: 751
RSpec/ExpectInHook
:
...
...
ee/spec/controllers/groups/analytics/coverage_reports_controller_spec.rb
View file @
deff21af
...
...
@@ -59,16 +59,16 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
stub_licensed_features
(
group_coverage_reports:
true
)
end
it
'responds 200 with CSV coverage data'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
described_class
.
name
,
'download_code_coverage_csv'
,
it
'responds 200 with CSV coverage data'
,
:snowplow
do
get
:index
,
params:
valid_request_params
expect_snowplow_event
(
category:
described_class
.
name
,
action:
'download_code_coverage_csv'
,
label:
'group_id'
,
value:
group
.
id
)
get
:index
,
params:
valid_request_params
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
csv_response
).
to
eq
([
%w[date group_name project_name coverage]
,
...
...
ee/spec/controllers/registrations_controller_spec.rb
View file @
deff21af
...
...
@@ -148,15 +148,15 @@ RSpec.describe RegistrationsController do
update_registration
end
it
'tracks a signed_up event'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
'Growth::Conversion::Experiment::OnboardingIssues'
,
'signed_up'
,
it
'tracks a signed_up event'
,
:snowplow
do
update_registration
expect_snowplow_event
(
category:
'Growth::Conversion::Experiment::OnboardingIssues'
,
action:
'signed_up'
,
label:
anything
,
property:
"
#{
group_type
}
_group"
)
update_registration
end
end
end
...
...
@@ -176,10 +176,10 @@ RSpec.describe RegistrationsController do
update_registration
end
it
'does not track a signed_up event'
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
it
'does not track a signed_up event'
,
:snowplow
do
update_registration
expect_no_snowplow_event
end
end
end
...
...
@@ -196,10 +196,10 @@ RSpec.describe RegistrationsController do
update_registration
end
it
'does not track a signed_up event'
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
it
'does not track a signed_up event'
,
:snowplow
do
update_registration
expect_no_snowplow_event
end
end
end
...
...
ee/spec/requests/api/visual_review_discussions_spec.rb
View file @
deff21af
...
...
@@ -58,9 +58,10 @@ RSpec.describe API::VisualReviewDiscussions do
stub_feature_flags
(
notes_create_service_tracking:
false
)
end
it
'does not track any events'
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
it
'does not track any events'
,
:snowplow
do
request
expect_no_snowplow_event
end
end
...
...
spec/controllers/groups_controller_spec.rb
View file @
deff21af
...
...
@@ -319,10 +319,10 @@ RSpec.describe GroupsController, factory_default: :keep do
stub_experiment
(
onboarding_issues:
false
)
end
it
'does not track anything'
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
it
'does not track anything'
,
:snowplow
do
create_namespace
expect_no_snowplow_event
end
end
...
...
@@ -336,15 +336,15 @@ RSpec.describe GroupsController, factory_default: :keep do
stub_experiment_for_user
(
onboarding_issues:
false
)
end
it
'tracks the event with the "created_namespace" action with the "control_group" property'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
'Growth::Conversion::Experiment::OnboardingIssues'
,
'created_namespace'
,
it
'tracks the event with the "created_namespace" action with the "control_group" property'
,
:snowplow
do
create_namespace
expect_snowplow_event
(
category:
'Growth::Conversion::Experiment::OnboardingIssues'
,
action:
'created_namespace'
,
label:
anything
,
property:
'control_group'
)
create_namespace
end
end
...
...
@@ -353,15 +353,15 @@ RSpec.describe GroupsController, factory_default: :keep do
stub_experiment_for_user
(
onboarding_issues:
true
)
end
it
'tracks the event with the "created_namespace" action with the "experimental_group" property'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
'Growth::Conversion::Experiment::OnboardingIssues'
,
'created_namespace'
,
it
'tracks the event with the "created_namespace" action with the "experimental_group" property'
,
:snowplow
do
create_namespace
expect_snowplow_event
(
category:
'Growth::Conversion::Experiment::OnboardingIssues'
,
action:
'created_namespace'
,
label:
anything
,
property:
'experimental_group'
)
create_namespace
end
end
end
...
...
spec/services/clusters/applications/check_installation_progress_service_spec.rb
View file @
deff21af
...
...
@@ -161,10 +161,10 @@ RSpec.describe Clusters::Applications::CheckInstallationProgressService, '#execu
expect
(
application
.
status_reason
).
to
be_nil
end
it
'tracks application install'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
'cluster:applications'
,
"cluster_application_helm_installed"
)
it
'tracks application install'
,
:snowplow
do
service
.
execute
expect_snowplow_event
(
category:
'cluster:applications'
,
action:
'cluster_application_helm_installed'
)
end
end
...
...
spec/services/issues/zoom_link_service_spec.rb
View file @
deff21af
...
...
@@ -46,10 +46,15 @@ RSpec.describe Issues::ZoomLinkService do
expect
(
ZoomMeeting
.
canonical_meeting_url
(
issue
)).
to
eq
(
zoom_link
)
end
it
'tracks the add event'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
)
.
with
(
'IncidentManagement::ZoomIntegration'
,
'add_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
it
'tracks the add event'
,
:snowplow
do
result
expect_snowplow_event
(
category:
'IncidentManagement::ZoomIntegration'
,
action:
'add_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
end
it
'creates a zoom_link_added notification'
do
...
...
@@ -180,10 +185,15 @@ RSpec.describe Issues::ZoomLinkService do
expect
(
ZoomMeeting
.
canonical_meeting_url
(
issue
)).
to
eq
(
nil
)
end
it
'tracks the remove event'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
)
.
with
(
'IncidentManagement::ZoomIntegration'
,
'remove_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
it
'tracks the remove event'
,
:snowplow
do
result
expect_snowplow_event
(
category:
'IncidentManagement::ZoomIntegration'
,
action:
'remove_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
end
end
...
...
spec/support/helpers/snowplow_helpers.rb
View file @
deff21af
...
...
@@ -36,10 +36,10 @@ module SnowplowHelpers
# would not pass any arguments when using **kwargs.
# https://gitlab.com/gitlab-org/gitlab/-/issues/263430
if
kwargs
.
present?
expect
(
Gitlab
::
Tracking
).
to
have_received
(
:event
)
expect
(
Gitlab
::
Tracking
).
to
have_received
(
:event
)
# rubocop:disable RSpec/ExpectGitlabTracking
.
with
(
category
,
action
,
**
kwargs
).
at_least
(
:once
)
else
expect
(
Gitlab
::
Tracking
).
to
have_received
(
:event
)
expect
(
Gitlab
::
Tracking
).
to
have_received
(
:event
)
# rubocop:disable RSpec/ExpectGitlabTracking
.
with
(
category
,
action
).
at_least
(
:once
)
end
end
...
...
@@ -56,6 +56,6 @@ module SnowplowHelpers
# end
# end
def
expect_no_snowplow_event
expect
(
Gitlab
::
Tracking
).
not_to
have_received
(
:event
)
expect
(
Gitlab
::
Tracking
).
not_to
have_received
(
:event
)
# rubocop:disable RSpec/ExpectGitlabTracking
end
end
spec/support/snowplow.rb
View file @
deff21af
...
...
@@ -13,7 +13,7 @@ RSpec.configure do |config|
stub_application_setting
(
snowplow_enabled:
true
)
allow
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
allow
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
# rubocop:disable RSpec/ExpectGitlabTracking
end
config
.
after
(
:each
,
:snowplow
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment