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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
c2bf452c
Commit
c2bf452c
authored
Dec 01, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ClustersController pagination test
parent
9199d30a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+1
-1
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+10
-11
No files found.
app/controllers/projects/clusters_controller.rb
View file @
c2bf452c
...
...
@@ -9,7 +9,7 @@ class Projects::ClustersController < Projects::ApplicationController
def
index
@scope
=
params
[
:scope
]
||
'all'
clusters
=
ClustersFinder
.
new
(
project
,
current_user
,
@scope
).
execute
@clusters
=
clusters
.
page
(
params
[
:page
])
.
per
(
20
)
@clusters
=
clusters
.
page
(
params
[
:page
])
@active_count
=
project
.
clusters
.
enabled
.
count
@inactive_count
=
project
.
clusters
.
disabled
.
count
@all_count
=
@active_count
+
@inactive_count
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
c2bf452c
...
...
@@ -33,20 +33,19 @@ describe Projects::ClustersController do
expect
(
assigns
(
:inactive_count
)).
to
eq
(
project
.
clusters
.
disabled
.
count
)
end
context
'properly paginates'
do
before
do
PAGE_LIMIT
=
20
project
.
clusters
=
create_list
(
:cluster
,
PAGE_LIMIT
+
1
,
:provided_by_gcp
,
projects:
[
project
])
end
context
'when page is specified'
do
let
(
:last_page
)
{
project
.
clusters
.
page
.
total_pages
}
it
'shows the first page'
do
go
expect
(
assigns
(
:clusters
).
count
).
to
eq
(
PAGE_LIMIT
)
before
do
Clusters
::
Cluster
.
paginates_per
(
1
)
create_list
(
:cluster
,
2
,
:provided_by_gcp
,
projects:
[
project
])
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
,
page:
last_page
end
it
'shows the second page'
do
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
,
page:
2
expect
(
assigns
(
:clusters
).
count
).
to
eq
(
1
)
it
'redirects to the page'
do
binding
.
pry
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
assigns
(
:clusters
).
current_page
).
to
eq
(
last_page
)
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