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
3c5150a1
Commit
3c5150a1
authored
Dec 13, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more specs and grape entity stuff
parent
2f808329
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
5 deletions
+27
-5
lib/api/entities.rb
lib/api/entities.rb
+5
-0
lib/api/users.rb
lib/api/users.rb
+17
-0
spec/lib/gitlab/user_activities_spec.rb
spec/lib/gitlab/user_activities_spec.rb
+2
-2
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+3
-3
No files found.
lib/api/entities.rb
View file @
3c5150a1
...
...
@@ -18,6 +18,11 @@ module API
expose
:bio
,
:location
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
end
class
UserActivity
<
Grape
::
Entity
expose
:username
expose
:date
end
class
Identity
<
Grape
::
Entity
expose
:provider
,
:extern_uid
end
...
...
lib/api/users.rb
View file @
3c5150a1
...
...
@@ -456,6 +456,23 @@ module API
email
.
destroy
current_user
.
update_secondary_emails!
end
desc
'Get a list of user activities'
do
success
Entities
::
UserBasic
end
params
do
optional
:due_date
,
type:
String
,
desc:
'Date time string in the format YEAR-MONTH-DAY'
use
:pagination
end
get
":activities"
do
authenticated_as_admin!
user_activities
=
Gitlab
::
UserActivities
.
query
(
from:
params
[
:from
],
page:
params
[
:page
],
per_page:
params
[
:per_page
])
present
paginate
(
user_activities
),
with:
Entities
::
UserActivity
end
end
end
end
spec/lib/gitlab/user_activities_spec.rb
View file @
3c5150a1
...
...
@@ -5,7 +5,7 @@ describe Gitlab::UserActivities, :redis, lib: true do
it
'shows the last user activities'
do
Timecop
.
freeze
do
Users
::
ActivityService
.
new
(
user
,
'type'
).
execute
user
.
record_activity
expect
(
described_class
.
query
).
to
eq
({
username:
user
.
username
,
last_activity:
DateTime
.
now
})
...
...
@@ -17,7 +17,7 @@ describe Gitlab::UserActivities, :redis, lib: true do
Timecop
.
scale
(
3600
)
7
.
times
do
Users
::
ActivityService
.
new
(
create
(
:user
),
'type'
).
execute
create
(
:user
).
record_activity
end
end
...
...
spec/requests/api/users_spec.rb
View file @
3c5150a1
...
...
@@ -1101,16 +1101,16 @@ describe API::Users, api: true do
end
end
context
"user activities"
do
context
"user activities"
,
:redis
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/users/activities"
,
user
)
}
end
context
'last activities'
do
it
'returns the last activities'
do
Users
::
ActivityService
.
new
(
user
,
'type'
).
execute
user
.
record_activity
get
api
(
"/users/activities"
,
user
)
get
api
(
"/users/activities"
,
admin
)
activity
=
json_response
.
first
...
...
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