BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b886a75d
Commit
b886a75d
authored
Jan 30, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jprovazn-pagination' into 'master'
Make pagination optional for issuables See merge request gitlab-org/gitlab-ce!16774
parents
7f647f9f
b02a6bed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+15
-5
issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+12
-0
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
b886a75d
...
@@ -12,11 +12,9 @@ module IssuableCollections
...
@@ -12,11 +12,9 @@ module IssuableCollections
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def
set_issuables_index
def
set_issuables_index
@issuables
=
issuables_collection
@issuables
=
issuables_collection
@issuables
=
@issuables
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issuables
,
collection_type
)
@total_pages
=
issuable_page_count
set_pagination
return
if
redirect_out_of_range
(
@total_pages
)
return
if
redirect_out_of_range
(
@total_pages
)
if
params
[
:label_name
].
present?
if
params
[
:label_name
].
present?
...
@@ -35,14 +33,26 @@ module IssuableCollections
...
@@ -35,14 +33,26 @@ module IssuableCollections
@users
.
push
(
author
)
if
author
@users
.
push
(
author
)
if
author
end
end
end
end
def
set_pagination
return
if
pagination_disabled?
@issuables
=
@issuables
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issuables
,
collection_type
)
@total_pages
=
issuable_page_count
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def
pagination_disabled?
false
end
def
issuables_collection
def
issuables_collection
finder
.
execute
.
preload
(
preload_for_collection
)
finder
.
execute
.
preload
(
preload_for_collection
)
end
end
def
redirect_out_of_range
(
total_pages
)
def
redirect_out_of_range
(
total_pages
)
return
false
if
total_pages
.
zero?
return
false
if
total_pages
.
nil?
||
total_pages
.
zero?
out_of_range
=
@issuables
.
current_page
>
total_pages
# rubocop:disable Gitlab/ModuleWithInstanceVariables
out_of_range
=
@issuables
.
current_page
>
total_pages
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
b886a75d
...
@@ -102,6 +102,18 @@ describe Projects::IssuesController do
...
@@ -102,6 +102,18 @@ describe Projects::IssuesController do
expect
(
response
).
to
redirect_to
(
namespace_project_issues_path
(
page:
last_page
,
state:
controller
.
params
[
:state
],
scope:
controller
.
params
[
:scope
]))
expect
(
response
).
to
redirect_to
(
namespace_project_issues_path
(
page:
last_page
,
state:
controller
.
params
[
:state
],
scope:
controller
.
params
[
:scope
]))
end
end
it
'does not use pagination if disabled'
do
allow
(
controller
).
to
receive
(
:pagination_disabled?
).
and_return
(
true
)
get
:index
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
page:
(
last_page
+
1
).
to_param
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
assigns
(
:issues
).
size
).
to
eq
(
2
)
end
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