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
ec9d360b
Commit
ec9d360b
authored
Aug 24, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track unique web ide edit action
parent
43e236b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
4 deletions
+33
-4
changelogs/unreleased/232839-fj-track-unique-edit-web-ide-action.yml
...unreleased/232839-fj-track-unique-edit-web-ide-action.yml
+5
-0
lib/api/commits.rb
lib/api/commits.rb
+4
-1
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+24
-3
No files found.
changelogs/unreleased/232839-fj-track-unique-edit-web-ide-action.yml
0 → 100644
View file @
ec9d360b
---
title
:
Track unique web ide edit action for usage ping
merge_request
:
40246
author
:
type
:
changed
lib/api/commits.rb
View file @
ec9d360b
...
...
@@ -136,7 +136,10 @@ module API
if
result
[
:status
]
==
:success
commit_detail
=
user_project
.
repository
.
commit
(
result
[
:result
])
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
increment_commits_count
if
find_user_from_warden
if
find_user_from_warden
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
increment_commits_count
Gitlab
::
UsageDataCounters
::
EditorUniqueCounter
.
track_web_ide_edit_action
(
author:
current_user
)
end
present
commit_detail
,
with:
Entities
::
CommitDetail
,
stats:
params
[
:stats
]
else
...
...
spec/requests/api/commits_spec.rb
View file @
ec9d360b
...
...
@@ -367,10 +367,31 @@ RSpec.describe API::Commits do
end
end
it
'does not increment the usage counters using access token authentication'
do
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
not_to
receive
(
:increment_commits_count
)
context
'when using access token authentication'
do
it
'does not increment the usage counters'
do
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
not_to
receive
(
:increment_commits_count
)
expect
(
::
Gitlab
::
UsageDataCounters
::
EditorUniqueCounter
).
not_to
receive
(
:track_web_ide_edit_action
)
post
api
(
url
,
user
),
params:
valid_c_params
post
api
(
url
,
user
),
params:
valid_c_params
end
end
context
'when using warden'
do
it
'increments usage counters'
,
:clean_gitlab_redis_shared_state
do
session_id
=
Rack
::
Session
::
SessionId
.
new
(
'6919a6f1bb119dd7396fadc38fd18d0d'
)
session_hash
=
{
'warden.user.user.key'
=>
[[
user
.
id
],
user
.
encrypted_password
[
0
,
29
]]
}
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
set
(
"session:gitlab:
#{
session_id
.
private_id
}
"
,
Marshal
.
dump
(
session_hash
))
end
cookies
[
Gitlab
::
Application
.
config
.
session_options
[
:key
]]
=
session_id
.
public_id
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
to
receive
(
:increment_commits_count
)
expect
(
::
Gitlab
::
UsageDataCounters
::
EditorUniqueCounter
).
to
receive
(
:track_web_ide_edit_action
)
post
api
(
url
),
params:
valid_c_params
end
end
context
'a new file in project repo'
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