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
d7a2e92c
Commit
d7a2e92c
authored
Dec 21, 2016
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
applies url_for so that we dont lose filters when redirecting
parent
805bbe88
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
11 deletions
+13
-11
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+1
-1
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
spec/controllers/dashboard/todos_controller_spec.rb
spec/controllers/dashboard/todos_controller_spec.rb
+2
-1
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+3
-2
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+4
-4
spec/controllers/projects/snippets_controller_spec.rb
spec/controllers/projects/snippets_controller_spec.rb
+1
-1
No files found.
app/controllers/dashboard/todos_controller.rb
View file @
d7a2e92c
...
...
@@ -5,7 +5,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
@sort
=
params
[
:sort
]
@todos
=
@todos
.
page
(
params
[
:page
])
if
@todos
.
out_of_range?
&&
@todos
.
total_pages
!=
0
redirect_to
dashboard_todos_path
(
page:
@todos
.
total_pages
)
redirect_to
url_for
(
params
.
merge
(
page:
@todos
.
total_pages
)
)
end
end
...
...
app/controllers/projects/issues_controller.rb
View file @
d7a2e92c
...
...
@@ -26,7 +26,7 @@ class Projects::IssuesController < Projects::ApplicationController
@issues
=
issues_collection
@issues
=
@issues
.
page
(
params
[
:page
])
if
@issues
.
out_of_range?
&&
@issues
.
total_pages
!=
0
return
redirect_to
namespace_project_issues_path
(
page:
@issues
.
total_pages
)
return
redirect_to
url_for
(
params
.
merge
(
page:
@issues
.
total_pages
)
)
end
if
params
[
:label_name
].
present?
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
d7a2e92c
...
...
@@ -39,7 +39,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_requests
=
merge_requests_collection
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
])
if
@merge_requests
.
out_of_range?
&&
@merge_requests
.
total_pages
!=
0
return
redirect_to
namespace_project_merge_requests_path
(
page:
@merge_requests
.
total_pages
)
return
redirect_to
url_for
(
params
.
merge
(
page:
@merge_requests
.
total_pages
)
)
end
if
params
[
:label_name
].
present?
...
...
spec/controllers/dashboard/todos_controller_spec.rb
View file @
d7a2e92c
...
...
@@ -13,10 +13,11 @@ describe Dashboard::TodosController do
context
'when using pagination'
do
let
(
:last_page
)
{
user
.
todos
.
page
().
total_pages
}
let!
(
:issues
)
{
create_list
(
:issue
,
30
,
project:
project
,
assignee:
user
)
}
let!
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
,
assignee:
user
)
}
before
do
issues
.
each
{
|
issue
|
todo_service
.
new_issue
(
issue
,
user
)
}
allow
(
Kaminari
.
config
).
to
receive
(
:default_per_page
).
and_return
(
1
)
end
it
'redirects to last_page if page number is larger than number of pages'
do
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
d7a2e92c
...
...
@@ -55,11 +55,12 @@ describe Projects::IssuesController do
context
'with page param'
do
let
(
:last_page
)
{
project
.
issues
.
page
().
total_pages
}
let!
(
:issue_list
)
{
create_list
(
:issue
,
30
,
project:
project
)
}
let!
(
:issue_list
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
allow
(
Kaminari
.
config
).
to
receive
(
:default_per_page
).
and_return
(
1
)
end
it
'redirects to last_page if page number is larger than number of pages'
do
...
...
@@ -68,7 +69,7 @@ describe Projects::IssuesController do
project_id:
project
.
path
.
to_param
,
page:
(
last_page
+
1
).
to_param
expect
(
response
).
to
redirect_to
(
namespace_project_issues_path
(
page:
last_page
))
expect
(
response
).
to
redirect_to
(
namespace_project_issues_path
(
page:
last_page
,
state:
controller
.
params
[
:state
],
scope:
controller
.
params
[
:scope
]
))
end
it
'redirects to specified page'
do
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
d7a2e92c
...
...
@@ -127,9 +127,6 @@ describe Projects::MergeRequestsController do
end
describe
'GET index'
do
let
(
:last_page
)
{
project
.
merge_requests
.
page
().
total_pages
}
let!
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
target_project:
project
,
source_project:
project
)
}
def
get_merge_requests
(
page
=
nil
)
get
:index
,
namespace_id:
project
.
namespace
.
to_param
,
...
...
@@ -138,10 +135,13 @@ describe Projects::MergeRequestsController do
end
context
'when page param'
do
let
(
:last_page
)
{
project
.
merge_requests
.
page
().
total_pages
}
let!
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
target_project:
project
,
source_project:
project
)
}
it
'redirects to last_page if page number is larger than number of pages'
do
get_merge_requests
(
last_page
+
1
)
expect
(
response
).
to
redirect_to
(
namespace_project_merge_requests_path
(
page:
last_page
))
expect
(
response
).
to
redirect_to
(
namespace_project_merge_requests_path
(
page:
last_page
,
state:
controller
.
params
[
:state
],
scope:
controller
.
params
[
:scope
]
))
end
it
'redirects to specified page'
do
...
...
spec/controllers/projects/snippets_controller_spec.rb
View file @
d7a2e92c
...
...
@@ -26,7 +26,7 @@ describe Projects::SnippetsController do
it
'redirects to specified page'
do
get
:index
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
page:
(
last_page
)
.
to_param
project_id:
project
.
path
,
page:
last_page
.
to_param
expect
(
assigns
(
:snippets
).
current_page
).
to
eq
(
last_page
)
expect
(
response
).
to
have_http_status
(
200
)
...
...
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