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
509c4830
Commit
509c4830
authored
Dec 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getting rid of pagination util and more refactoring of specs
parent
922e6cf0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
59 deletions
+31
-59
lib/gitlab/pagination_util.rb
lib/gitlab/pagination_util.rb
+0
-21
lib/gitlab/user_activities/activity_set.rb
lib/gitlab/user_activities/activity_set.rb
+8
-1
spec/lib/gitlab/pagination_util_spec.rb
spec/lib/gitlab/pagination_util_spec.rb
+0
-34
spec/lib/gitlab/user_activities/activity_set_spec.rb
spec/lib/gitlab/user_activities/activity_set_spec.rb
+20
-2
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+3
-1
No files found.
lib/gitlab/pagination_util.rb
deleted
100644 → 0
View file @
922e6cf0
module
Gitlab
module
PaginationUtil
delegate
:total_count
,
:total_pages
,
:current_page
,
:limit_value
,
:first_page?
,
:prev_page
,
:last_page?
,
:next_page
,
to: :pagination_delegate
# requires a Gitlab::PaginationDelegate instance with the default configuration.
# Example:
# @pagination_delegate ||= Gitlab::PaginationDelegate.new(page: 1,
# per_page: 10,
# count: 20)
def
pagination_delegate
raise
NotImplementedError
.
new
(
"Expected
#{
self
.
class
.
name
}
to implement
#{
__method__
}
"
)
end
end
end
lib/gitlab/user_activities/activity_set.rb
View file @
509c4830
module
Gitlab
module
UserActivities
class
ActivitySet
include
Gitlab
::
PaginationUtil
delegate
:total_count
,
:total_pages
,
:current_page
,
:limit_value
,
:first_page?
,
:prev_page
,
:last_page?
,
:next_page
,
to: :pagination_delegate
KEY
=
'user/activities'
...
...
spec/lib/gitlab/pagination_util_spec.rb
deleted
100644 → 0
View file @
922e6cf0
require
'spec_helper'
describe
Gitlab
::
PaginationUtil
,
lib:
true
do
context
'class with no pagination delegate defined'
do
let
(
:pagination_class
)
{
Class
.
new
{
extend
Gitlab
::
PaginationUtil
}
}
it
'throws an error calling the method'
do
expect
{
pagination_class
.
pagination_delegate
}.
to
raise_error
(
NotImplementedError
)
end
end
context
'class with no pagination delegate defined'
do
let
(
:pagination_class
)
{
Class
.
new
{
extend
Gitlab
::
PaginationUtil
}
}
let
(
:pagination_delegate
)
do
Gitlab
::
PaginationDelegate
.
new
(
page:
1
,
per_page:
10
,
count:
20
)
end
let
(
:delegated_methods
)
{
%i[total_count total_pages current_page limit_value first_page? prev_page last_page? next_page]
}
before
do
allow
(
pagination_class
).
to
receive
(
:pagination_delegate
).
and_return
(
pagination_delegate
)
end
it
'does not throw an error'
do
expect
{
pagination_class
.
pagination_delegate
}.
not_to
raise_error
end
it
'includes the delegated methods'
do
expect
(
pagination_class
.
public_methods
).
to
include
(
*
delegated_methods
)
end
end
end
spec/lib/gitlab/user_activities/activity_set_spec.rb
View file @
509c4830
...
...
@@ -11,6 +11,24 @@ describe Gitlab::UserActivities::ActivitySet, :redis, lib: true do
end
end
context
'pagination delegation'
do
let
(
:pagination_delegate
)
do
Gitlab
::
PaginationDelegate
.
new
(
page:
1
,
per_page:
10
,
count:
20
)
end
let
(
:delegated_methods
)
{
%i[total_count total_pages current_page limit_value first_page? prev_page last_page? next_page]
}
before
do
allow
(
described_class
.
new
).
to
receive
(
:pagination_delegate
).
and_return
(
pagination_delegate
)
end
it
'includes the delegated methods'
do
expect
(
described_class
.
new
.
public_methods
).
to
include
(
*
delegated_methods
)
end
end
context
'paginated activities'
do
before
do
Timecop
.
scale
(
3600
)
...
...
@@ -44,13 +62,13 @@ describe Gitlab::UserActivities::ActivitySet, :redis, lib: true do
create
(
:user
).
record_activity
end
it
'shows activities from
yester
day'
do
it
'shows activities from
to
day'
do
today
=
Date
.
today
.
to_s
(
"%Y-%m-%d"
)
expect
(
described_class
.
new
(
from:
today
).
activities
.
count
).
to
eq
(
1
)
end
it
'filter activities from to
day
'
do
it
'filter activities from to
morrow
'
do
tomorrow
=
Date
.
tomorrow
.
to_s
(
"%Y-%m-%d"
)
expect
(
described_class
.
new
(
from:
tomorrow
).
activities
.
count
).
to
eq
(
0
)
...
...
spec/requests/api/users_spec.rb
View file @
509c4830
...
...
@@ -1118,6 +1118,8 @@ describe API::Users, api: true do
context
'last activity as admin'
do
it
'returns the last activity'
do
allow
(
Time
).
to
receive
(
:now
).
and_return
(
Time
.
new
(
2000
,
1
,
1
))
user
.
record_activity
get
api
(
"/user/activities"
,
admin
)
...
...
@@ -1125,7 +1127,7 @@ describe API::Users, api: true do
activity
=
json_response
.
last
expect
(
activity
[
'username'
]).
to
eq
(
user
.
username
)
expect
(
activity
[
'last_activity_at'
]).
to
start_with
(
Date
.
today
.
year
.
to_s
)
expect
(
activity
[
'last_activity_at'
]).
to
eq
(
'2000-01-01 00:00:00'
)
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