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:
...
@@ -186,31 +186,21 @@ RSpec/ExpectChange:
# Offense count: 47
# Offense count: 47
RSpec/ExpectGitlabTracking
:
RSpec/ExpectGitlabTracking
:
Exclude
:
Exclude
:
-
'
ee/spec/controllers/groups/analytics/coverage_reports_controller_spec.rb'
-
'
ee/spec/controllers/projects/settings/operations_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/requests/api/visual_review_discussions_spec.rb'
-
'
ee/spec/services/epics/issue_promote_service_spec.rb'
-
'
ee/spec/services/epics/issue_promote_service_spec.rb'
-
'
spec/controllers/groups/registry/repositories_controller_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/repositories_controller_spec.rb'
-
'
spec/controllers/projects/registry/tags_controller_spec.rb'
-
'
spec/controllers/projects/registry/tags_controller_spec.rb'
-
'
spec/controllers/projects/settings/operations_controller_spec.rb'
-
'
spec/controllers/projects/settings/operations_controller_spec.rb'
-
'
spec/controllers/registrations_controller_spec.rb'
-
'
spec/controllers/registrations_controller_spec.rb'
-
'
spec/lib/api/helpers_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/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/controllers/trackable_shared_examples.rb'
-
'
spec/support/shared_examples/requests/api/container_repositories_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/discussions_shared_examples.rb'
-
'
spec/support/shared_examples/requests/api/packages_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/shared_examples/requests/api/tracking_shared_examples.rb'
-
'
spec/support/snowplow.rb'
# Offense count: 751
# Offense count: 751
RSpec/ExpectInHook
:
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
...
@@ -59,16 +59,16 @@ RSpec.describe Groups::Analytics::CoverageReportsController do
stub_licensed_features
(
group_coverage_reports:
true
)
stub_licensed_features
(
group_coverage_reports:
true
)
end
end
it
'responds 200 with CSV coverage data'
do
it
'responds 200 with CSV coverage data'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
get
:index
,
params:
valid_request_params
described_class
.
name
,
'download_code_coverage_csv'
,
expect_snowplow_event
(
category:
described_class
.
name
,
action:
'download_code_coverage_csv'
,
label:
'group_id'
,
label:
'group_id'
,
value:
group
.
id
value:
group
.
id
)
)
get
:index
,
params:
valid_request_params
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
csv_response
).
to
eq
([
expect
(
csv_response
).
to
eq
([
%w[date group_name project_name coverage]
,
%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
...
@@ -148,15 +148,15 @@ RSpec.describe RegistrationsController do
update_registration
update_registration
end
end
it
'tracks a signed_up event'
do
it
'tracks a signed_up event'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
update_registration
'Growth::Conversion::Experiment::OnboardingIssues'
,
'signed_up'
,
expect_snowplow_event
(
category:
'Growth::Conversion::Experiment::OnboardingIssues'
,
action:
'signed_up'
,
label:
anything
,
label:
anything
,
property:
"
#{
group_type
}
_group"
property:
"
#{
group_type
}
_group"
)
)
update_registration
end
end
end
end
end
end
...
@@ -176,10 +176,10 @@ RSpec.describe RegistrationsController do
...
@@ -176,10 +176,10 @@ RSpec.describe RegistrationsController do
update_registration
update_registration
end
end
it
'does not track a signed_up event'
do
it
'does not track a signed_up event'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
update_registration
update_registration
expect_no_snowplow_event
end
end
end
end
end
end
...
@@ -196,10 +196,10 @@ RSpec.describe RegistrationsController do
...
@@ -196,10 +196,10 @@ RSpec.describe RegistrationsController do
update_registration
update_registration
end
end
it
'does not track a signed_up event'
do
it
'does not track a signed_up event'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
update_registration
update_registration
expect_no_snowplow_event
end
end
end
end
end
end
...
...
ee/spec/requests/api/visual_review_discussions_spec.rb
View file @
deff21af
...
@@ -58,9 +58,10 @@ RSpec.describe API::VisualReviewDiscussions do
...
@@ -58,9 +58,10 @@ RSpec.describe API::VisualReviewDiscussions do
stub_feature_flags
(
notes_create_service_tracking:
false
)
stub_feature_flags
(
notes_create_service_tracking:
false
)
end
end
it
'does not track any events'
do
it
'does not track any events'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
request
request
expect_no_snowplow_event
end
end
end
end
...
...
spec/controllers/groups_controller_spec.rb
View file @
deff21af
...
@@ -319,10 +319,10 @@ RSpec.describe GroupsController, factory_default: :keep do
...
@@ -319,10 +319,10 @@ RSpec.describe GroupsController, factory_default: :keep do
stub_experiment
(
onboarding_issues:
false
)
stub_experiment
(
onboarding_issues:
false
)
end
end
it
'does not track anything'
do
it
'does not track anything'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
create_namespace
create_namespace
expect_no_snowplow_event
end
end
end
end
...
@@ -336,15 +336,15 @@ RSpec.describe GroupsController, factory_default: :keep do
...
@@ -336,15 +336,15 @@ RSpec.describe GroupsController, factory_default: :keep do
stub_experiment_for_user
(
onboarding_issues:
false
)
stub_experiment_for_user
(
onboarding_issues:
false
)
end
end
it
'tracks the event with the "created_namespace" action with the "control_group" property'
do
it
'tracks the event with the "created_namespace" action with the "control_group" property'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
create_namespace
'Growth::Conversion::Experiment::OnboardingIssues'
,
'created_namespace'
,
expect_snowplow_event
(
category:
'Growth::Conversion::Experiment::OnboardingIssues'
,
action:
'created_namespace'
,
label:
anything
,
label:
anything
,
property:
'control_group'
property:
'control_group'
)
)
create_namespace
end
end
end
end
...
@@ -353,15 +353,15 @@ RSpec.describe GroupsController, factory_default: :keep do
...
@@ -353,15 +353,15 @@ RSpec.describe GroupsController, factory_default: :keep do
stub_experiment_for_user
(
onboarding_issues:
true
)
stub_experiment_for_user
(
onboarding_issues:
true
)
end
end
it
'tracks the event with the "created_namespace" action with the "experimental_group" property'
do
it
'tracks the event with the "created_namespace" action with the "experimental_group" property'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
create_namespace
'Growth::Conversion::Experiment::OnboardingIssues'
,
'created_namespace'
,
expect_snowplow_event
(
category:
'Growth::Conversion::Experiment::OnboardingIssues'
,
action:
'created_namespace'
,
label:
anything
,
label:
anything
,
property:
'experimental_group'
property:
'experimental_group'
)
)
create_namespace
end
end
end
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
...
@@ -161,10 +161,10 @@ RSpec.describe Clusters::Applications::CheckInstallationProgressService, '#execu
expect
(
application
.
status_reason
).
to
be_nil
expect
(
application
.
status_reason
).
to
be_nil
end
end
it
'tracks application install'
do
it
'tracks application install'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
'cluster:applications'
,
"cluster_application_helm_installed"
)
service
.
execute
service
.
execute
expect_snowplow_event
(
category:
'cluster:applications'
,
action:
'cluster_application_helm_installed'
)
end
end
end
end
...
...
spec/services/issues/zoom_link_service_spec.rb
View file @
deff21af
...
@@ -46,10 +46,15 @@ RSpec.describe Issues::ZoomLinkService do
...
@@ -46,10 +46,15 @@ RSpec.describe Issues::ZoomLinkService do
expect
(
ZoomMeeting
.
canonical_meeting_url
(
issue
)).
to
eq
(
zoom_link
)
expect
(
ZoomMeeting
.
canonical_meeting_url
(
issue
)).
to
eq
(
zoom_link
)
end
end
it
'tracks the add event'
do
it
'tracks the add event'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
)
.
with
(
'IncidentManagement::ZoomIntegration'
,
'add_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
result
result
expect_snowplow_event
(
category:
'IncidentManagement::ZoomIntegration'
,
action:
'add_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
end
end
it
'creates a zoom_link_added notification'
do
it
'creates a zoom_link_added notification'
do
...
@@ -180,10 +185,15 @@ RSpec.describe Issues::ZoomLinkService do
...
@@ -180,10 +185,15 @@ RSpec.describe Issues::ZoomLinkService do
expect
(
ZoomMeeting
.
canonical_meeting_url
(
issue
)).
to
eq
(
nil
)
expect
(
ZoomMeeting
.
canonical_meeting_url
(
issue
)).
to
eq
(
nil
)
end
end
it
'tracks the remove event'
do
it
'tracks the remove event'
,
:snowplow
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
)
.
with
(
'IncidentManagement::ZoomIntegration'
,
'remove_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
result
result
expect_snowplow_event
(
category:
'IncidentManagement::ZoomIntegration'
,
action:
'remove_zoom_meeting'
,
label:
'Issue ID'
,
value:
issue
.
id
)
end
end
end
end
...
...
spec/support/helpers/snowplow_helpers.rb
View file @
deff21af
...
@@ -36,10 +36,10 @@ module SnowplowHelpers
...
@@ -36,10 +36,10 @@ module SnowplowHelpers
# would not pass any arguments when using **kwargs.
# would not pass any arguments when using **kwargs.
# https://gitlab.com/gitlab-org/gitlab/-/issues/263430
# https://gitlab.com/gitlab-org/gitlab/-/issues/263430
if
kwargs
.
present?
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
)
.
with
(
category
,
action
,
**
kwargs
).
at_least
(
:once
)
else
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
)
.
with
(
category
,
action
).
at_least
(
:once
)
end
end
end
end
...
@@ -56,6 +56,6 @@ module SnowplowHelpers
...
@@ -56,6 +56,6 @@ module SnowplowHelpers
# end
# end
# end
# end
def
expect_no_snowplow_event
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
end
end
spec/support/snowplow.rb
View file @
deff21af
...
@@ -13,7 +13,7 @@ RSpec.configure do |config|
...
@@ -13,7 +13,7 @@ RSpec.configure do |config|
stub_application_setting
(
snowplow_enabled:
true
)
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
end
config
.
after
(
:each
,
:snowplow
)
do
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