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
d1a7ecf6
Commit
d1a7ecf6
authored
Dec 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing failing spec and renamed user namespace to avoid conflicts
parent
62000466
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
8 deletions
+67
-8
app/models/user.rb
app/models/user.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+3
-3
lib/gitlab/user_activities/activity.rb
lib/gitlab/user_activities/activity.rb
+1
-1
lib/gitlab/user_activities/activity_set.rb
lib/gitlab/user_activities/activity_set.rb
+2
-2
spec/lib/gitlab/user_activities/activity_set_spec.rb
spec/lib/gitlab/user_activities/activity_set_spec.rb
+59
-0
spec/lib/gitlab/user_activities/activity_spec.rb
spec/lib/gitlab/user_activities/activity_spec.rb
+1
-1
No files found.
app/models/user.rb
View file @
d1a7ecf6
...
...
@@ -948,7 +948,7 @@ class User < ActiveRecord::Base
end
def
record_activity
Gitlab
::
User
::
ActivitySet
.
record
(
self
)
Gitlab
::
User
Activities
::
ActivitySet
.
record
(
self
)
end
private
...
...
lib/api/users.rb
View file @
d1a7ecf6
...
...
@@ -467,9 +467,9 @@ module API
get
":activities"
do
authenticated_as_admin!
activity_set
=
Gitlab
::
User
::
ActivitySet
.
new
(
from:
params
[
:from
],
page:
params
[
:page
],
per_page:
params
[
:per_page
])
activity_set
=
Gitlab
::
User
Activities
::
ActivitySet
.
new
(
from:
params
[
:from
],
page:
params
[
:page
],
per_page:
params
[
:per_page
])
add_pagination_headers
(
activity_set
)
...
...
lib/gitlab/user/activity.rb
→
lib/gitlab/user
_activities
/activity.rb
View file @
d1a7ecf6
module
Gitlab
module
User
module
User
Activities
class
Activity
attr_reader
:username
...
...
lib/gitlab/user/activity_set.rb
→
lib/gitlab/user
_activities
/activity_set.rb
View file @
d1a7ecf6
module
Gitlab
module
User
module
User
Activities
class
ActivitySet
include
Gitlab
::
PaginationUtil
...
...
@@ -12,7 +12,7 @@ module Gitlab
end
end
def
initialize
(
from
:
,
page
:,
per_page
:
)
def
initialize
(
from:
nil
,
page:
nil
,
per_page:
nil
)
@from
=
sanitize_date
(
from
)
@to
=
Time
.
now
.
to_i
@page
=
page
...
...
spec/lib/gitlab/user/activity_set_spec.rb
→
spec/lib/gitlab/user
_activities
/activity_set_spec.rb
View file @
d1a7ecf6
require
'spec_helper'
describe
Gitlab
::
User
::
ActivitySet
,
:redis
,
lib:
true
do
describe
Gitlab
::
User
Activities
::
ActivitySet
,
:redis
,
lib:
true
do
let
(
:user
)
{
create
(
:user
)
}
it
'shows the last user activit
ies
'
do
it
'shows the last user activit
y
'
do
Timecop
.
freeze
do
user
.
record_activity
expect
(
described_class
.
query
).
to
eq
({
username:
user
.
username
,
last_activity:
DateTime
.
now
})
expect
(
described_class
.
new
.
activities
.
first
).
to
be_an_instance_of
(
Gitlab
::
UserActivities
::
Activity
)
end
end
...
...
@@ -26,34 +25,35 @@ describe Gitlab::User::ActivitySet, :redis, lib: true do
end
it
'shows the 5 oldest user activities paginated'
do
expect
(
described_class
.
query
(
per_page:
5
)
.
count
).
to
eq
(
5
)
expect
(
described_class
.
new
(
per_page:
5
).
activities
.
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
)
expect
(
described_class
.
new
(
per_page:
5
,
page:
2
).
activities
.
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
activities
=
described_class
.
new
.
activities
expect
(
activities
.
first
.
last_activity_at
).
to
be
<
activities
.
last
.
last_activity_at
end
end
context
'filter by date'
do
before
do
Timecop
.
freeze
(
Date
.
yesterday
)
end
after
do
Timecop
.
return
create
(
:user
).
record_activity
end
it
'shows activities from yesterday'
do
expect
(
described_class
.
query
(
from:
Date
.
yesterday
).
count
).
to
eq
(
1
)
today
=
Date
.
today
.
to_s
(
"%Y-%m-%d"
)
expect
(
described_class
.
new
(
from:
today
).
activities
.
count
).
to
eq
(
1
)
end
it
'filter activities from today'
do
expect
(
described_class
.
query
(
from:
Date
.
today
).
count
).
to
eq
(
0
)
tomorrow
=
Date
.
tomorrow
.
to_s
(
"%Y-%m-%d"
)
expect
(
described_class
.
new
(
from:
tomorrow
).
activities
.
count
).
to
eq
(
0
)
end
end
end
spec/lib/gitlab/user/activity_spec.rb
→
spec/lib/gitlab/user
_activities
/activity_spec.rb
View file @
d1a7ecf6
require
'spec_helper'
describe
Gitlab
::
User
::
Activity
,
:redis
,
lib:
true
do
describe
Gitlab
::
User
Activities
::
Activity
,
:redis
,
lib:
true
do
let
(
:username
)
{
'user'
}
let
(
:activity
)
{
described_class
.
new
(
'user'
,
Time
.
new
(
2016
,
12
,
12
).
to_i
)
}
...
...
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