Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koller <mkoller@gitlab.com>2019-09-03 20:45:00 +0300
committerMarkus Koller <mkoller@gitlab.com>2019-09-10 16:24:29 +0300
commitf1926b321deb8b922dead991fb4d8bea42699f9f (patch)
tree7dfb7b613152cc6282b1f169e781f11f736de36a /app/controllers/projects/snippets_controller.rb
parent60755fbc406bd25ab526339899f97a2b27aeb272 (diff)
Add controller concern for paginated collections
We had similar code in a few places to redirect to the last page if the given page number is out of range. This unifies the handling in a new controller concern and adds usage of it in all snippet listings.
Diffstat (limited to 'app/controllers/projects/snippets_controller.rb')
-rw-r--r--app/controllers/projects/snippets_controller.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb
index c84e9fbc2d7..dbd11c8ddc8 100644
--- a/app/controllers/projects/snippets_controller.rb
+++ b/app/controllers/projects/snippets_controller.rb
@@ -6,6 +6,7 @@ class Projects::SnippetsController < Projects::ApplicationController
include SpammableActions
include SnippetsActions
include RendersBlob
+ include PaginatedCollection
include Gitlab::NoteableMetadata
skip_before_action :verify_authenticity_token,
@@ -34,9 +35,7 @@ class Projects::SnippetsController < Projects::ApplicationController
.page(params[:page])
.inc_author
- if @snippets.out_of_range? && @snippets.total_pages != 0
- return redirect_to project_snippets_path(@project, page: @snippets.total_pages)
- end
+ return if redirect_out_of_range(@snippets)
@noteable_meta_data = noteable_meta_data(@snippets, 'Snippet')
end