From a1baf6f9ada83b66ed4f1f58c86cab989782edfe Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 10 Jun 2024 14:00:07 +0300 Subject: [PATCH] Relax min id value for paging to include 0 --- app/controllers/concerns/pagination_methods.rb | 4 ++-- test/controllers/diary_entries_controller_test.rb | 2 +- test/controllers/traces_controller_test.rb | 2 +- test/controllers/user_blocks_controller_test.rb | 2 +- test/controllers/users/diary_comments_controller_test.rb | 2 +- test/controllers/users/issued_blocks_controller_test.rb | 2 +- test/controllers/users/lists_controller_test.rb | 2 +- test/controllers/users/received_blocks_controller_test.rb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/concerns/pagination_methods.rb b/app/controllers/concerns/pagination_methods.rb index 23eb8c724..ec4556779 100644 --- a/app/controllers/concerns/pagination_methods.rb +++ b/app/controllers/concerns/pagination_methods.rb @@ -6,8 +6,8 @@ module PaginationMethods ## # limit selected items to one page, get ids of first item before/after the page def get_page_items(items, includes: [], limit: 20, cursor_column: :id) - param! :before, Integer, :min => 1 - param! :after, Integer, :min => 1 + param! :before, Integer, :min => 0 + param! :after, Integer, :min => 0 qualified_cursor_column = "#{items.table_name}.#{cursor_column}" page_items = if params[:before] diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index f3f45d238..35ce238bb 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -510,7 +510,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest def test_index_invalid_paged # Try some invalid paged accesses - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get diary_entries_path(:before => id) assert_redirected_to :controller => :errors, :action => :bad_request diff --git a/test/controllers/traces_controller_test.rb b/test/controllers/traces_controller_test.rb index 45746e213..1cf209f2b 100644 --- a/test/controllers/traces_controller_test.rb +++ b/test/controllers/traces_controller_test.rb @@ -299,7 +299,7 @@ class TracesControllerTest < ActionDispatch::IntegrationTest def test_index_invalid_paged # Try some invalid paged accesses - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get traces_path(:before => id) assert_redirected_to :controller => :errors, :action => :bad_request diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index ddb33e903..bb8f3808b 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -92,7 +92,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest ## # test the index action with invalid pages def test_index_invalid_paged - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get user_blocks_path(:before => id) assert_redirected_to :controller => :errors, :action => :bad_request diff --git a/test/controllers/users/diary_comments_controller_test.rb b/test/controllers/users/diary_comments_controller_test.rb index 372cc3282..723cae08a 100644 --- a/test/controllers/users/diary_comments_controller_test.rb +++ b/test/controllers/users/diary_comments_controller_test.rb @@ -58,7 +58,7 @@ module Users def test_index_invalid_paged user = create(:user) - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get user_diary_comments_path(user, :before => id) assert_redirected_to :controller => "/errors", :action => :bad_request diff --git a/test/controllers/users/issued_blocks_controller_test.rb b/test/controllers/users/issued_blocks_controller_test.rb index 4fab264e9..369766d51 100644 --- a/test/controllers/users/issued_blocks_controller_test.rb +++ b/test/controllers/users/issued_blocks_controller_test.rb @@ -83,7 +83,7 @@ module Users def test_show_invalid_paged user = create(:moderator_user) - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get user_issued_blocks_path(user, :before => id) assert_redirected_to :controller => "/errors", :action => :bad_request diff --git a/test/controllers/users/lists_controller_test.rb b/test/controllers/users/lists_controller_test.rb index 6326bdb18..53037d17f 100644 --- a/test/controllers/users/lists_controller_test.rb +++ b/test/controllers/users/lists_controller_test.rb @@ -190,7 +190,7 @@ module Users def test_show_invalid_paginated session_for(create(:administrator_user)) - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get users_list_path(:before => id) assert_redirected_to :controller => "/errors", :action => :bad_request diff --git a/test/controllers/users/received_blocks_controller_test.rb b/test/controllers/users/received_blocks_controller_test.rb index a48a7e2cd..32924fd23 100644 --- a/test/controllers/users/received_blocks_controller_test.rb +++ b/test/controllers/users/received_blocks_controller_test.rb @@ -91,7 +91,7 @@ module Users def test_show_invalid_paged user = create(:user) - %w[-1 0 fred].each do |id| + %w[-1 fred].each do |id| get user_received_blocks_path(user, :before => id) assert_redirected_to :controller => "/errors", :action => :bad_request -- 2.39.5