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
e5686a29
Commit
e5686a29
authored
Dec 12, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added relevant specs
parent
62a4637d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
spec/lib/gitlab/user_activities_spec.rb
spec/lib/gitlab/user_activities_spec.rb
+59
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+18
-0
No files found.
spec/lib/gitlab/user_activities_spec.rb
0 → 100644
View file @
e5686a29
require
'spec_helper'
describe
Gitlab
::
UserActivities
,
:redis
,
lib:
true
do
let
(
:user
)
{
create
(
:user
)
}
it
'shows the last user activities'
do
Timecop
.
freeze
do
Users
::
ActivityService
.
new
(
user
,
'type'
).
execute
expect
(
described_class
.
query
).
to
eq
({
username:
user
.
username
,
last_activity:
DateTime
.
now
})
end
end
context
'paginated activities'
do
before
do
Timecop
.
scale
(
3600
)
7
.
times
do
Users
::
ActivityService
.
new
(
create
(
:user
),
'type'
).
execute
end
end
after
do
Timecop
.
return
end
it
'shows the 5 oldest user activities paginated'
do
expect
(
described_class
.
query
(
per_page:
5
).
count
).
to
eq
(
5
)
end
it
'shows the 2 reamining user activities paginated'
do
expect
(
described_class
.
query
(
per_page:
5
,
page:
1
).
count
).
to
eq
(
2
)
end
it
'shows the oldest first'
do
# FIXME
expect
(
described_class
.
query
.
first
.
second
).
to
be
<
described_class
.
query
.
last
.
second
end
end
context
'filter by date'
do
before
do
Timecop
.
freeze
(
Date
.
yesterday
)
end
after
do
Timecop
.
return
end
it
'shows activities from yesterday'
do
expect
(
described_class
.
query
(
from:
Date
.
yesterday
).
count
).
to
eq
(
1
)
end
it
'filter activities from today'
do
expect
(
described_class
.
query
(
from:
Date
.
today
).
count
).
to
eq
(
0
)
end
end
end
spec/requests/api/users_spec.rb
View file @
e5686a29
...
...
@@ -1100,4 +1100,22 @@ describe API::Users, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
end
context
"user activities"
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
get
api
(
"/users/activities"
,
user
)
activity
=
json_response
.
first
expect
(
activity
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
end
end
end
end
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