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
477359a2
Commit
477359a2
authored
Apr 09, 2020
by
Doug Stull
Committed by
Heinrich Lee Yu
Apr 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track notification dot
- needed for metrics
parent
27b453cb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
0 deletions
+98
-0
ee/app/views/layouts/header/_user_notification_dot.html.haml
ee/app/views/layouts/header/_user_notification_dot.html.haml
+3
-0
ee/spec/features/buy_ci_minutes_notification_dot_spec.rb
ee/spec/features/buy_ci_minutes_notification_dot_spec.rb
+49
-0
ee/spec/views/layouts/application.html.haml_spec.rb
ee/spec/views/layouts/application.html.haml_spec.rb
+39
-0
lib/gitlab/tracking.rb
lib/gitlab/tracking.rb
+7
-0
No files found.
ee/app/views/layouts/header/_user_notification_dot.html.haml
View file @
477359a2
-
return
unless
show_user_notification_dot?
(
project
,
namespace
)
-# Tracking events from the template is not ideal and we are moving this to the client in https://gitlab.com/gitlab-org/gitlab/-/issues/213712
-
track_event
(
'show_buy_ci_minutes_notification'
,
label:
current_user
.
namespace
.
actual_plan_name
,
property:
'user_dropdown'
)
%span
.header-user-notification-dot.rounded-circle.position-relative
ee/spec/features/buy_ci_minutes_notification_dot_spec.rb
0 → 100644
View file @
477359a2
# frozen_string_literal: true
require
'spec_helper'
describe
'User notification dot'
,
:aggregate_failures
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
,
creator:
user
,
shared_runners_enabled:
true
)
}
let
(
:group
)
{
create
(
:group
)
}
let!
(
:user_pipelines
)
{
create
(
:ci_pipeline
,
user:
user
,
project:
project
)
}
before
do
stub_experiment_for_user
(
ci_notification_dot:
true
)
group
.
add_developer
(
user
)
sign_in
(
user
)
end
context
'when ci minutes are below threshold'
do
before
do
group
.
update
(
last_ci_minutes_usage_notification_level:
30
,
shared_runners_minutes_limit:
10
)
allow_any_instance_of
(
EE
::
Namespace
).
to
receive
(
:shared_runners_remaining_minutes
).
and_return
(
2
)
end
it
'shows notification dot'
do
expect_next_instance_of
(
ProjectsController
)
do
|
ctrl
|
expect
(
ctrl
).
to
receive
(
:track_event
)
.
with
(
'show_buy_ci_minutes_notification'
,
label:
'free'
,
property:
'user_dropdown'
)
end
visit
project_path
(
project
)
expect
(
page
).
to
have_css
(
'span'
,
class:
'header-user-notification-dot'
)
end
end
context
'when ci minutes are not below threshold'
do
let
(
:group
)
{
create
(
:group
,
:with_not_used_build_minutes_limit
)
}
it
'shows notification dot'
do
expect_next_instance_of
(
ProjectsController
)
do
|
ctrl
|
expect
(
ctrl
).
not_to
receive
(
:track_event
)
end
visit
project_path
(
project
)
expect
(
page
).
not_to
have_css
(
'span'
,
class:
'header-user-notification-dot'
)
end
end
end
ee/spec/views/layouts/application.html.haml_spec.rb
0 → 100644
View file @
477359a2
# frozen_string_literal: true
require
'spec_helper'
describe
'layouts/application'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:show_notification_dot
)
{
false
}
before
do
allow
(
view
).
to
receive
(
:experiment_enabled?
).
and_return
(
false
)
allow
(
view
).
to
receive
(
:session
).
and_return
({})
allow
(
view
).
to
receive
(
:user_signed_in?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive
(
:current_user_mode
).
and_return
(
Gitlab
::
Auth
::
CurrentUserMode
.
new
(
user
))
allow
(
view
).
to
receive
(
:show_user_notification_dot?
).
and_return
(
show_notification_dot
)
end
describe
'layouts/_user_notification_dot'
do
context
'when we show the notification dot'
do
let
(
:show_notification_dot
)
{
true
}
it
'has the notification dot'
do
expect
(
view
).
to
receive
(
:track_event
).
with
(
'show_buy_ci_minutes_notification'
,
label:
'free'
,
property:
'user_dropdown'
)
render
expect
(
rendered
).
to
have_css
(
'span'
,
class:
'header-user-notification-dot'
)
end
end
context
'when we do not show the notification dot'
do
it
'does not have the notification dot'
do
render
expect
(
rendered
).
not_to
have_css
(
'span'
,
class:
'header-user-notification-dot'
)
end
end
end
end
lib/gitlab/tracking.rb
View file @
477359a2
...
...
@@ -9,6 +9,13 @@ module Gitlab
module
ControllerConcern
extend
ActiveSupport
::
Concern
included
do
# Tracking events from the template is not ideal and we are moving this to the client in https://gitlab.com/gitlab-org/gitlab/-/issues/213712
# In the meantime, using this method from the view is frowned upon and this line will likely be removed
# in the near future
helper_method
:track_event
end
protected
def
track_event
(
action
=
action_name
,
**
args
)
...
...
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