From f1926b321deb8b922dead991fb4d8bea42699f9f Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Tue, 3 Sep 2019 19:45:00 +0200 Subject: 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. --- app/controllers/projects/snippets_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'app/controllers/projects/snippets_controller.rb') 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 -- cgit v1.2.3