diff --git a/.simplecov b/.simplecov
index ae18afbbe..a37d7ede5 100644
--- a/.simplecov
+++ b/.simplecov
@@ -27,8 +27,10 @@ SimpleCov.start do
add_group 'Calendar', %w[gem/lib/pagy/calendar
gem/lib/pagy/extras/calendar.rb]
add_group 'Keyset', %w[gem/lib/pagy/keyset.rb
+ gem/lib/pagy/keyset_for_ui.rb
gem/lib/pagy/keyset/active_record.rb
gem/lib/pagy/keyset/sequel.rb
- gem/lib/pagy/extras/keyset.rb]
+ gem/lib/pagy/extras/keyset.rb
+ gem/lib/pagy/extras/keyset_for_ui.rb]
add_group 'Tests', %w[test]
end
diff --git a/e2e/cypress/e2e/demo.cy.ts b/e2e/cypress/e2e/demo.cy.ts
index 69c3ca1a6..96760c2ac 100644
--- a/e2e/cypress/e2e/demo.cy.ts
+++ b/e2e/cypress/e2e/demo.cy.ts
@@ -19,7 +19,7 @@ for (const path of paths) {
testComboNav(app, "#combo-nav-js");
testInfo(app, "#pagy-info", path);
if (path === "/pagy") {
- testLimitSelector(app, "#limit-selector-js", path, true); // trim true
+ testLimitSelector(app, "#limit-selector-js", path);
}
});
}
diff --git a/e2e/cypress/e2e/rails.cy.ts b/e2e/cypress/e2e/rails.cy.ts
index bc665c2f3..1d4298b07 100644
--- a/e2e/cypress/e2e/rails.cy.ts
+++ b/e2e/cypress/e2e/rails.cy.ts
@@ -10,6 +10,6 @@ describe(`[${app}] Test helpers`, () => {
testNav(app, "#nav", {pages: ["3"]});
testNav(app, "#nav-js", {pages: ["3"]});
testComboNav(app, "#combo-nav-js");
- testLimitSelector(app, "#limit-selector-js"); // no style, no trim
+ testLimitSelector(app, "#limit-selector-js");
testInfo(app, "#pagy-info");
});
diff --git a/e2e/cypress/e2e/repro.cy.ts b/e2e/cypress/e2e/repro.cy.ts
index 09bb97cae..b8ff6181a 100644
--- a/e2e/cypress/e2e/repro.cy.ts
+++ b/e2e/cypress/e2e/repro.cy.ts
@@ -11,5 +11,5 @@ describe(`[${app}] Test helpers`, () => {
testNav(app, "#nav-js-responsive", {rjs: true});
testComboNav(app, "#combo-nav-js");
testInfo(app, "#pagy-info");
- testLimitSelector(app, "#limit-selector-js"); // no style, no trim
+ testLimitSelector(app, "#limit-selector-js");
});
diff --git a/e2e/snapshots.js b/e2e/snapshots.js
index 2f61f481a..2b26e5007 100644
--- a/e2e/snapshots.js
+++ b/e2e/snapshots.js
@@ -14,61 +14,61 @@ module.exports = {
},
"[demo] Test #nav-js": {
"1": "
@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": ""
+ "10": ""
},
"[demo] Test #nav-js-responsive": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "12": "",
+ "12": "",
"13": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "14": "",
+ "14": "",
"15": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "16": "",
+ "16": "",
"17": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "18": "",
+ "18": "",
"19": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "20": "",
+ "20": "",
"21": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "22": "",
+ "22": "",
"23": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "24": "",
+ "24": "",
"25": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "26": "",
+ "26": "",
"27": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "28": "",
+ "28": "",
"29": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "30": ""
+ "30": ""
},
"[demo] Test #combo-nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records:\n 941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960\n
",
- "12": ""
+ "12": ""
},
"[demo] Test #pagy-info": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
@@ -80,47 +80,29 @@ module.exports = {
},
"[demo] Test #limit-selector-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records: 1,2,3,4,5,6,7,8,9,10
",
- "4": "",
+ "4": "",
"5": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
",
- "6": "",
+ "6": "",
"7": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
",
- "8": "",
- "9": "",
- "10": "",
- "11": "",
- "12": "",
- "13": "",
- "14": "",
- "15": "@records:\n 701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720\n
",
- "16": "",
- "17": "@records: 701,702,703,704,705,706,707,708,709,710
",
- "18": "",
- "19": "@records:\n 698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714
",
- "20": "",
- "21": "@records:\n 685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702
",
- "22": "",
- "23": "",
- "24": "",
- "25": "",
- "26": "",
- "27": "",
- "28": "",
- "29": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "30": "",
- "31": "@records: 981,982,983,984,985,986,987,988,989,990
",
- "32": "",
- "33": "@records:\n 970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986
",
- "34": "",
- "35": "@records:\n 955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972
",
- "36": "",
- "37": "",
- "38": "",
- "39": "",
- "40": "",
- "41": "",
- "42": ""
+ "8": "",
+ "9": "@records:\n 701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720\n
",
+ "10": "",
+ "11": "@records: 701,702,703,704,705,706,707,708,709,710
",
+ "12": "",
+ "13": "@records:\n 698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714
",
+ "14": "",
+ "15": "@records:\n 685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702
",
+ "16": "",
+ "17": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
+ "18": "",
+ "19": "@records: 981,982,983,984,985,986,987,988,989,990
",
+ "20": "",
+ "21": "@records:\n 970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986
",
+ "22": "",
+ "23": "@records:\n 955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972
",
+ "24": ""
}
},
"[demo] Test /bootstrap helpers": {
@@ -138,61 +120,61 @@ module.exports = {
},
"[demo] Test #nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": ""
+ "10": ""
},
"[demo] Test #nav-js-responsive": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "12": "",
+ "12": "",
"13": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "14": "",
+ "14": "",
"15": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "16": "",
+ "16": "",
"17": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "18": "",
+ "18": "",
"19": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "20": "",
+ "20": "",
"21": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "22": "",
+ "22": "",
"23": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "24": "",
+ "24": "",
"25": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "26": "",
+ "26": "",
"27": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "28": "",
+ "28": "",
"29": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "30": ""
+ "30": ""
},
"[demo] Test #combo-nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records:\n 941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960\n
",
- "12": ""
+ "12": ""
},
"[demo] Test #pagy-info": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
@@ -218,61 +200,61 @@ module.exports = {
},
"[demo] Test #nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": ""
+ "10": ""
},
"[demo] Test #nav-js-responsive": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "12": "",
+ "12": "",
"13": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "14": "",
+ "14": "",
"15": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "16": "",
+ "16": "",
"17": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "18": "",
+ "18": "",
"19": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "20": "",
+ "20": "",
"21": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "22": "",
+ "22": "",
"23": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "24": "",
+ "24": "",
"25": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "26": "",
+ "26": "",
"27": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "28": "",
+ "28": "",
"29": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "30": ""
+ "30": ""
},
"[demo] Test #combo-nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records:\n 941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960\n
",
- "12": ""
+ "12": ""
},
"[demo] Test #pagy-info": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
@@ -283,7 +265,7 @@ module.exports = {
"6": "Displaying items 981-1000 of 1000 in total"
}
},
- "__version": "13.16.0",
+ "__version": "13.17.0",
"[repro] Test helpers": {
"[repro] Test #nav": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
@@ -299,61 +281,61 @@ module.exports = {
},
"[repro] Test #nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": ""
+ "10": ""
},
"[repro] Test #nav-js-responsive": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "12": "",
+ "12": "",
"13": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "14": "",
+ "14": "",
"15": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "16": "",
+ "16": "",
"17": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "18": "",
+ "18": "",
"19": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "20": "",
+ "20": "",
"21": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "22": "",
+ "22": "",
"23": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "24": "",
+ "24": "",
"25": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "26": "",
+ "26": "",
"27": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "28": "",
+ "28": "",
"29": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "30": ""
+ "30": ""
},
"[repro] Test #combo-nav-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records:\n 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
",
- "4": "",
+ "4": "",
"5": "@records:\n 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
",
- "6": "",
+ "6": "",
"7": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "8": "",
+ "8": "",
"9": "@records:\n 961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980\n
",
- "10": "",
+ "10": "",
"11": "@records:\n 941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960\n
",
- "12": ""
+ "12": ""
},
"[repro] Test #pagy-info": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
@@ -365,29 +347,29 @@ module.exports = {
},
"[repro] Test #limit-selector-js": {
"1": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
",
- "2": "",
+ "2": "",
"3": "@records: 1,2,3,4,5,6,7,8,9,10
",
- "4": "",
+ "4": "",
"5": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
",
- "6": "",
+ "6": "",
"7": "@records: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
",
- "8": "",
+ "8": "",
"9": "@records:\n 701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720\n
",
- "10": "",
+ "10": "",
"11": "@records: 701,702,703,704,705,706,707,708,709,710
",
- "12": "",
+ "12": "",
"13": "@records:\n 698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714
",
- "14": "",
+ "14": "",
"15": "@records:\n 685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702
",
- "16": "",
+ "16": "",
"17": "@records:\n 981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000\n
",
- "18": "",
+ "18": "",
"19": "@records: 981,982,983,984,985,986,987,988,989,990
",
- "20": "",
+ "20": "",
"21": "@records:\n 970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986
",
- "22": "",
+ "22": "",
"23": "@records:\n 955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972
",
- "24": ""
+ "24": ""
}
},
"[rails] Test helpers": {
@@ -403,53 +385,53 @@ module.exports = {
},
"[rails] Test #nav-js": {
"1": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
- "2": "",
+ "2": "",
"3": "\n
Comment 1 to Post 6
\n
Comment 2 to Post 6
\n
Comment 1 to Post 7
\n
Comment 2 to Post 7
\n
Comment 1 to Post 8
\n
Comment 2 to Post 8
\n
Comment 1 to Post 9
\n
Comment 2 to Post 9
\n
Comment 1 to Post 10
\n
Comment 2 to Post 10
\n
",
- "4": "",
+ "4": "",
"5": "\n
Comment 1 to Post 11
\n
Comment 2 to Post 11
\n
",
- "6": "",
+ "6": "",
"7": "\n
Comment 1 to Post 6
\n
Comment 2 to Post 6
\n
Comment 1 to Post 7
\n
Comment 2 to Post 7
\n
Comment 1 to Post 8
\n
Comment 2 to Post 8
\n
Comment 1 to Post 9
\n
Comment 2 to Post 9
\n
Comment 1 to Post 10
\n
Comment 2 to Post 10
\n
",
- "8": ""
+ "8": ""
},
"[rails] Test #combo-nav-js": {
"1": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
- "2": "",
+ "2": "",
"3": "\n
Comment 1 to Post 6
\n
Comment 2 to Post 6
\n
Comment 1 to Post 7
\n
Comment 2 to Post 7
\n
Comment 1 to Post 8
\n
Comment 2 to Post 8
\n
Comment 1 to Post 9
\n
Comment 2 to Post 9
\n
Comment 1 to Post 10
\n
Comment 2 to Post 10
\n
",
- "4": "",
+ "4": "",
"5": "\n
Comment 1 to Post 11
\n
Comment 2 to Post 11
\n
",
- "6": "",
+ "6": "",
"7": "\n
Comment 1 to Post 11
\n
Comment 2 to Post 11
\n
",
- "8": "",
+ "8": "",
"9": "\n
Comment 1 to Post 6
\n
Comment 2 to Post 6
\n
Comment 1 to Post 7
\n
Comment 2 to Post 7
\n
Comment 1 to Post 8
\n
Comment 2 to Post 8
\n
Comment 1 to Post 9
\n
Comment 2 to Post 9
\n
Comment 1 to Post 10
\n
Comment 2 to Post 10
\n
",
- "10": "",
+ "10": "",
"11": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
- "12": ""
+ "12": ""
},
"[rails] Test #limit-selector-js": {
"1": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
- "2": "",
+ "2": "",
"3": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
- "4": "",
+ "4": "",
"5": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
- "6": "",
+ "6": "",
"7": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
Comment 1 to Post 6
\n
",
- "8": "",
+ "8": "",
"9": "\n
",
- "10": "",
+ "10": "",
"11": "\n
",
- "12": "",
+ "12": "",
"13": "\n
",
- "14": "",
+ "14": "",
"15": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
Comment 1 to Post 6
\n
",
- "16": "",
+ "16": "",
"17": "\n
",
- "18": "",
+ "18": "",
"19": "\n
",
- "20": "",
+ "20": "",
"21": "\n
",
- "22": "",
+ "22": "",
"23": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
Comment 1 to Post 6
\n
",
- "24": ""
+ "24": ""
},
"[rails] Test #pagy-info": {
"1": "\n
Comment 1 to Post 1
\n
Comment 2 to Post 1
\n
Comment 1 to Post 2
\n
Comment 2 to Post 2
\n
Comment 1 to Post 3
\n
Comment 2 to Post 3
\n
Comment 1 to Post 4
\n
Comment 2 to Post 4
\n
Comment 1 to Post 5
\n
Comment 2 to Post 5
\n
",
diff --git a/test/helpers/nav_tests.rb b/test/helpers/nav_tests.rb
index afa036ecd..5ad59a9b9 100644
--- a/test/helpers/nav_tests.rb
+++ b/test/helpers/nav_tests.rb
@@ -1,8 +1,10 @@
# frozen_string_literal: true
require 'pagy/extras/countless'
+require 'pagy/extras/keyset_for_ui'
require_relative '../mock_helpers/pagy_buggy'
require_relative '../mock_helpers/app'
+require_relative '../files/models'
module NavTests
def app
@@ -12,12 +14,16 @@ def app
def nav_tests(prefix)
method = :"pagy#{prefix}_nav"
[1, 20, 50].each do |page|
- pagy = Pagy.new(count: 1000, page: page)
+ pagy = Pagy.new(count: 1000, page: page)
pagyx = Pagy.new(count: 1000, page: page)
_(app.send(method, pagy)).must_rematch :"plain_#{page}"
_(app.send(method, pagyx, id: 'test-nav-id', anchor_string: 'anchor_string')).must_rematch :"extras_#{page}"
end
_ { app.send(method, PagyBuggy.new(count: 100)) }.must_raise Pagy::InternalError
+ pagyk = Pagy::KeysetForUI.new(Pet.order(:animal, :name, :id),
+ cutoffs: ['key', 2, ["cat", "Ella", 18], nil],
+ page: 2)
+ _(app.send(method, pagyk)).must_rematch :keyset
end
def nav_js_tests(prefix) # e.g. pagy_bootstrap_nav_js
diff --git a/test/mock_helpers/app.rb b/test/mock_helpers/app.rb
index 9643230db..4e1e176ef 100644
--- a/test/mock_helpers/app.rb
+++ b/test/mock_helpers/app.rb
@@ -8,17 +8,17 @@
# Backend and Frontend poor man mock app
class MockApp
- attr_reader :params, :request, :response
+ attr_reader :request, :response
- include Pagy::Backend
- include Pagy::Frontend
+ def initialize(url: 'http://example.com:3000/foo', params: { page: 3 }, cookie: nil)
+ env = Rack::MockRequest.env_for(url, params: params)
+ env["HTTP_COOKIE"] = cookie if cookie
+ @request = Rack::Request.new(env)
+ @response = Rack::Response.new
+ end
- # App params are merged into the @request.params (and are all strings)
- # @params are taken from @request.params and merged with app params (which fixes symbols and strings in params)
- def initialize(url: 'http://example.com:3000/foo', params: { page: 3 })
- @request = Rack::Request.new(Rack::MockRequest.env_for(url, params: params))
- @params = ActiveSupport::HashWithIndifferentAccess.new(@request.params).merge(params)
- @response = Rack::Response.new
+ def params
+ ActiveSupport::HashWithIndifferentAccess.new(@request.params)
end
def test_i18n_call
@@ -29,6 +29,9 @@ def set_pagy_locale(locale) # rubocop:disable Naming/AccessorMethodName
@pagy_locale = locale
end
+ include Pagy::Backend
+ include Pagy::Frontend
+
class Calendar < MockApp
def pagy_calendar_period(collection)
starting = collection.minimum(:time)
diff --git a/test/pagy/backend_test.rb b/test/pagy/backend_test.rb
index 707b54117..652fa38b3 100644
--- a/test/pagy/backend_test.rb
+++ b/test/pagy/backend_test.rb
@@ -17,7 +17,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.count).must_equal Pagy::DEFAULT[:limit]
_(records).must_equal [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]
end
diff --git a/test/pagy/extras/arel_test.rb b/test/pagy/extras/arel_test.rb
index 7f3a9ea94..373078808 100644
--- a/test/pagy/extras/arel_test.rb
+++ b/test/pagy/extras/arel_test.rb
@@ -19,7 +19,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.size).must_equal Pagy::DEFAULT[:limit]
_(records).must_equal [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]
end
diff --git a/test/pagy/extras/array_test.rb b/test/pagy/extras/array_test.rb
index 68b4ae9ef..ecb3ee835 100644
--- a/test/pagy/extras/array_test.rb
+++ b/test/pagy/extras/array_test.rb
@@ -17,7 +17,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.count).must_equal Pagy::DEFAULT[:limit]
_(records).must_equal [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]
end
diff --git a/test/pagy/extras/bootstrap_test.rb b/test/pagy/extras/bootstrap_test.rb
index 19eface58..69016bacc 100644
--- a/test/pagy/extras/bootstrap_test.rb
+++ b/test/pagy/extras/bootstrap_test.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative '../../test_helper'
+require_relative '../../helpers/nav_tests'
EXTRA = 'bootstrap'
PREFIX = '_bootstrap'
diff --git a/test/pagy/extras/bootstrap_test.rb.yaml b/test/pagy/extras/bootstrap_test.rb.yaml
index 41990cc2a..f6df58fa1 100644
--- a/test/pagy/extras/bootstrap_test.rb.yaml
+++ b/test/pagy/extras/bootstrap_test.rb.yaml
@@ -1,4 +1,54 @@
---
+pagy/extras/bootstrap___pagy_bootstrap_combo_nav_js_test_0001_renders_first,_intermediate_and_last_pages:
+ :plain_1: ''
+ :extras_1: ''
+ :plain_3: ''
+ :extras_3: ''
+ :plain_6: ''
+ :extras_6: ''
pagy/extras/bootstrap___pagy_bootstrap_nav_test_0001_renders_first,_intermediate_and_last_pages:
:plain_1:
-pagy/extras/bootstrap___pagy_bootstrap_combo_nav_js_test_0001_renders_first,_intermediate_and_last_pages:
- :plain_1: ''
- :extras_1: ''
- :plain_3: ''
- :extras_3: ''
- :plain_6: ''
- :extras_6: ''
-pagy/extras/bootstrap___pagy_bootstrap_nav_js_test_0001_renders_single_and_multiple_pages_when_used_with_Pagy__Countless:
- :plain_1_0:
- :extras_1_0:
- :plain_2_23:
- :extras_2_23:
+ :keyset:
pagy/extras/bootstrap___pagy_bootstrap_nav_js_test_0002_renders_first,_intermediate_and_last_pages_with_required_steps:
- :plain_1:
+ :plain_1:
:extras_1:
- :plain_20:
+ data-pagy="WyJuYXZfanMiLHsiYmVmb3JlIjoiPHVsIGNsYXNzPVwicGFnaW5hdGlvblwiPjxsaSBjbGFzcz1cInBhZ2UtaXRlbSBwcmV2IGRpc2FibGVkXCI+PGEgcm9sZT1cImxpbmtcIiBjbGFzcz1cInBhZ2UtbGlua1wiIGFyaWEtZGlzYWJsZWQ9XCJ0cnVlXCIgYXJpYS1sYWJlbD1cIlByZXZpb3VzXCI+Jmx0OzwvYT48L2xpPiIsImEiOiI8bGkgY2xhc3M9XCJwYWdlLWl0ZW1cIj48YSBhbmNob3Jfc3RyaW5nIGhyZWY9XCIvZm9vP3BhZ2U9X19wYWd5X3BhZ2VfX1wiIGNsYXNzPVwicGFnZS1saW5rXCI+X19wYWd5X2xhYmVsX188L2E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mtcIj5fX3BhZ3lfbGFiZWxfXzwvYT48L2xpPiIsImN1cnJlbnQiOiI8bGkgY2xhc3M9XCJwYWdlLWl0ZW0gYWN0aXZlXCI+PGEgcm9sZT1cImxpbmtcIiBjbGFzcz1cInBhZ2UtbGlua1wiIGFyaWEtY3VycmVudD1cInBhZ2VcIiBhcmlhLWRpc2FibGVkPVwidHJ1ZVwiPl9fcGFneV9sYWJlbF9fPC9hPjwvbGk+IiwiZ2FwIjoiPGxpIGNsYXNzPVwicGFnZS1pdGVtIGdhcCBkaXNhYmxlZFwiPjxhIHJvbGU9XCJsaW5rXCIgY2xhc3M9XCJwYWdlLWxpbmtcIiBhcmlhLWRpc2FibGVkPVwidHJ1ZVwiPiZoZWxsaXA7PC9hPjwvbGk+IiwiYWZ0ZXIiOiI8bGkgY2xhc3M9XCJwYWdlLWl0ZW0gbmV4dCBkaXNhYmxlZFwiPjxhIHJvbGU9XCJsaW5rXCIgY2xhc3M9XCJwYWdlLWxpbmtcIiBhcmlhLWRpc2FibGVkPVwidHJ1ZVwiIGFyaWEtbGFiZWw9XCJOZXh0XCI+Jmd0OzwvYT48L2xpPjwvdWw+In0seyIwIjpbNDYsNDcsNDgsNDksIjUwIl0sIjYwMCI6WzEsImdhcCIsNDYsNDcsNDgsNDksIjUwIl19LG51bGxd">
+pagy/extras/bootstrap___pagy_bootstrap_nav_js_test_0001_renders_single_and_multiple_pages_when_used_with_Pagy__Countless:
+ :plain_1_0:
+ :extras_1_0:
+ :plain_2_23:
+ :extras_2_23:
diff --git a/test/pagy/extras/bulma_test.rb b/test/pagy/extras/bulma_test.rb
index dcfe46415..eba06fddf 100644
--- a/test/pagy/extras/bulma_test.rb
+++ b/test/pagy/extras/bulma_test.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative '../../test_helper'
+require_relative '../../helpers/nav_tests'
EXTRA = 'bulma'
PREFIX = '_bulma'
diff --git a/test/pagy/extras/bulma_test.rb.yaml b/test/pagy/extras/bulma_test.rb.yaml
index 6ba5e681e..d775a31c0 100644
--- a/test/pagy/extras/bulma_test.rb.yaml
+++ b/test/pagy/extras/bulma_test.rb.yaml
@@ -1,69 +1,16 @@
---
-pagy/extras/bulma___pagy_bulma_nav_test_0001_renders_first,_intermediate_and_last_pages:
- :plain_1:
- :extras_1:
- :plain_20:
- :extras_20:
- :plain_50:
- :extras_50:
pagy/extras/bulma___pagy_bulma_combo_nav_js_test_0001_renders_first,_intermediate_and_last_pages:
:plain_1: ''
:extras_1: ''
:plain_3: ''
:extras_3: ''
:plain_6: ''
:extras_6: ''
-pagy/extras/bulma___pagy_bulma_nav_js_test_0001_renders_single_and_multiple_pages_when_used_with_Pagy__Countless:
- :plain_1_0:
- :extras_1_0:
- :plain_2_23:
- :extras_2_23:
pagy/extras/bulma___pagy_bulma_nav_js_test_0002_renders_first,_intermediate_and_last_pages_with_required_steps:
:plain_1:
+ data-pagy="WyJuYXZfanMiLHsiYmVmb3JlIjoiPGEgcm9sZT1cImxpbmtcIiBjbGFzcz1cInBhZ2luYXRpb24tcHJldmlvdXNcIiBkaXNhYmxlZCBhcmlhLWRpc2FibGVkPVwidHJ1ZVwiIGFyaWEtbGFiZWw9XCJQcmV2aW91c1wiPiZsdDs8L2E+PGEgaHJlZj1cIi9mb28/cGFnZT0yXCIgY2xhc3M9XCJwYWdpbmF0aW9uLW5leHRcIiBhcmlhLWxhYmVsPVwiTmV4dFwiPiZndDs8L2E+PHVsIGNsYXNzPVwicGFnaW5hdGlvbi1saXN0XCI+IiwiYSI6IjxsaT48YSBocmVmPVwiL2Zvbz9wYWdlPV9fcGFneV9wYWdlX19cIiBjbGFzcz1cInBhZ2luYXRpb24tbGlua1wiPl9fcGFneV9sYWJlbF9fPC9hPjwvbGk+IiwiY3VycmVudCI6IjxsaT48YSByb2xlPVwibGlua1wiIGNsYXNzPVwicGFnaW5hdGlvbi1saW5rIGlzLWN1cnJlbnRcIiBhcmlhLWN1cnJlbnQ9XCJwYWdlXCIgYXJpYS1kaXNhY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D1cInBhZ2VcIiBhcmlhLWRpc2FibGVkPVwidHJ1ZVwiPl9fcGFneV9sYWJlbF9fPC9hPjwvbGk+IiwiZ2FwIjoiPGxpPjxzcGFuIGNsYXNzPVwicGFnaW5hdGlvbi1lbGxpcHNpc1wiPiZoZWxsaXA7PC9zcGFuPjwvbGk+IiwiYWZ0ZXIiOiI8L3VsPiJ9LHsiMCI6WzQ2LDQ3LDQ4LDQ5LCI1MCJdLCI2MDAiOlsxLCJnYXAiLDQ2LDQ3LDQ4LDQ5LCI1MCJdfSxudWxsXQ==">
+pagy/extras/bulma___pagy_bulma_nav_js_test_0001_renders_single_and_multiple_pages_when_used_with_Pagy__Countless:
+ :plain_1_0:
+ :extras_1_0:
+ :plain_2_23:
+ :extras_2_23:
+pagy/extras/bulma___pagy_bulma_nav_test_0001_renders_first,_intermediate_and_last_pages:
+ :plain_1:
+ :extras_1:
+ :plain_20:
+ :extras_20:
+ :plain_50:
+ :extras_50:
+ :keyset:
diff --git a/test/pagy/extras/data_helpers_test.rb b/test/pagy/extras/data_helpers_test.rb
new file mode 100644
index 000000000..0b7d7911d
--- /dev/null
+++ b/test/pagy/extras/data_helpers_test.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+OJ = %i[without_oj with_oj].freeze
+OJ.each do |test|
+ require 'oj' if test == :with_oj
+
+ require_relative '../../test_helper'
+ require_relative '../../mock_helpers/app'
+
+ Time.zone = 'EST'
+ Date.beginning_of_week = :sunday
+
+ describe "pagy_data #{test}" do
+ let(:app) { MockApp.new(params: {}) }
+
+ describe "pagy_data #{test}" do
+ it "runs #{test}" do
+ _(app.pagy_data(Pagy.new(count: 10), :test_function, 'some-string', 123, true)).must_rematch :data_1
+ end
+ end
+ end
+end
diff --git a/test/pagy/extras/data_helpers_test.rb.yaml b/test/pagy/extras/data_helpers_test.rb.yaml
new file mode 100644
index 000000000..a15c47608
--- /dev/null
+++ b/test/pagy/extras/data_helpers_test.rb.yaml
@@ -0,0 +1,5 @@
+---
+pagy_data_with_oj__pagy_data_with_oj_test_0001_runs_with_oj:
+ :data_1: data-pagy="WyJ0ZXN0X2Z1bmN0aW9uIiwic29tZS1zdHJpbmciLDEyMyx0cnVlXQ=="
+pagy_data_without_oj__pagy_data_without_oj_test_0001_runs_without_oj:
+ :data_1: data-pagy="WyJ0ZXN0X2Z1bmN0aW9uIiwic29tZS1zdHJpbmciLDEyMyx0cnVlXQ=="
diff --git a/test/pagy/extras/elasticsearch_rails_test.rb b/test/pagy/extras/elasticsearch_rails_test.rb
index 43b2925ac..8ff624792 100644
--- a/test/pagy/extras/elasticsearch_rails_test.rb
+++ b/test/pagy/extras/elasticsearch_rails_test.rb
@@ -36,7 +36,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.count).must_equal Pagy::DEFAULT[:limit]
_(records).must_rematch :records
end
@@ -46,7 +46,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.count).must_equal Pagy::DEFAULT[:limit]
_(records).must_rematch :records
end
@@ -86,7 +86,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.count).must_equal Pagy::DEFAULT[:limit]
_(records).must_rematch :records
end
@@ -96,7 +96,7 @@
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.limit).must_equal Pagy::DEFAULT[:limit]
- _(pagy.page).must_equal app.params[:page]
+ _(pagy.page).must_equal app.params[:page].to_i
_(records.count).must_equal Pagy::DEFAULT[:limit]
_(records).must_rematch :records
end
diff --git a/test/pagy/extras/headers_test.rb b/test/pagy/extras/headers_test.rb
index 5ddf4d825..0c0f11a9b 100644
--- a/test/pagy/extras/headers_test.rb
+++ b/test/pagy/extras/headers_test.rb
@@ -79,7 +79,7 @@
it 'returns custom headers hash' do
pagy, _records = app.send(:pagy_keyset,
Pet.order(:id),
- page: 'eyJpZCI6MjB9',
+ page: 'WzIwXQ',
headers: { limit: 'Per-Page', page: 'Page', count: 'Total', pages: false })
_(app.send(:pagy_headers, pagy)).must_rematch :headers
end
diff --git a/test/pagy/extras/headers_test.rb.yaml b/test/pagy/extras/headers_test.rb.yaml
index 6bcbf00b5..cd583904e 100644
--- a/test/pagy/extras/headers_test.rb.yaml
+++ b/test/pagy/extras/headers_test.rb.yaml
@@ -1,47 +1,10 @@
---
-pagy/extras/headers___pagy_headers_merge_test_0001_returns_the_full_headers_hash:
- :response: !ruby/hash:Rack::Headers
- link: ; rel="first", ;
- rel="prev", ; rel="next", ;
- rel="last"
- current-page: '3'
- page-items: '20'
- total-pages: '50'
- total-count: '1000'
-pagy/extras/headers___pagy_headers_merge_with_Calendar_test_0001_returns_the_full_headers_hash:
- :response: !ruby/hash:Rack::Headers
- link: ; rel="first", ;
- rel="prev", ; rel="next", ;
- rel="last"
- current-page: '3'
- page-items: '20'
- total-pages: '26'
- total-count: '505'
-pagy/extras/headers___pagy_headers_with_Keyset_test_0003_omit_next_on_last_page:
- :headers:
- link: ; rel="first"
- page-items: '50'
-pagy/extras/headers___pagy_headers_with_Keyset_test_0002_returns_custom_headers_hash:
- :headers:
- link: ; rel="first", ;
- rel="next"
- Page: eyJpZCI6MjB9
- Per-Page: '20'
-pagy/extras/headers___pagy_headers_with_Keyset_test_0001_returns_the_full_headers_hash:
- :headers:
- link: ; rel="first", ;
- rel="next"
- page-items: '20'
-pagy/extras/headers___pagy_headers_test_0004_returns_the_countless_headers_hash:
- :headers:
- link: ; rel="first", ;
- rel="next"
- current-page: '1'
- page-items: '20'
-pagy/extras/headers___pagy_headers_test_0003_returns_custom_headers_hash:
+pagy/extras/headers___pagy_headers_test_0002_returns_custom_headers_hash:
:headers:
link: ; rel="first", ;
rel="next", ; rel="last"
+ Per-Page: '20'
+ Total: '1000'
pagy/extras/headers___pagy_headers_test_0006_omit_next_on_last_page:
:headers:
link: ; rel="first", ;
@@ -50,6 +13,12 @@ pagy/extras/headers___pagy_headers_test_0006_omit_next_on_last_page:
page-items: '20'
total-pages: '50'
total-count: '1000'
+pagy/extras/headers___pagy_headers_test_0004_returns_the_countless_headers_hash:
+ :headers:
+ link: ; rel="first", ;
+ rel="next"
+ current-page: '1'
+ page-items: '20'
pagy/extras/headers___pagy_headers_test_0001_returns_the_full_headers_hash:
:headers:
link: ; rel="first", ;
@@ -58,12 +27,10 @@ pagy/extras/headers___pagy_headers_test_0001_returns_the_full_headers_hash:
page-items: '20'
total-pages: '50'
total-count: '1000'
-pagy/extras/headers___pagy_headers_test_0002_returns_custom_headers_hash:
+pagy/extras/headers___pagy_headers_test_0003_returns_custom_headers_hash:
:headers:
link: ; rel="first", ;
rel="next", ; rel="last"
- Per-Page: '20'
- Total: '1000'
pagy/extras/headers___pagy_headers_test_0005_omit_prev_on_first_page:
:headers:
link: ; rel="first", ;
@@ -72,16 +39,45 @@ pagy/extras/headers___pagy_headers_test_0005_omit_prev_on_first_page:
page-items: '20'
total-pages: '50'
total-count: '1000'
-pagy/extras/headers___pagy_headers_with_Calendar_test_0004_returns_the_countless_headers_hash:
+pagy/extras/headers___pagy_headers_merge_test_0001_returns_the_full_headers_hash:
+ :response: !ruby/hash:Rack::Headers
+ link: ; rel="first", ;
+ rel="prev", ; rel="next", ;
+ rel="last"
+ current-page: '3'
+ page-items: '20'
+ total-pages: '50'
+ total-count: '1000'
+pagy/extras/headers___pagy_headers_with_Keyset_test_0002_returns_custom_headers_hash:
:headers:
- link: ; rel="first", ;
+ link: ; rel="first", ;
+ rel="next"
+ Page: WzIwXQ
+ Per-Page: '20'
+pagy/extras/headers___pagy_headers_with_Keyset_test_0003_omit_next_on_last_page:
+ :headers:
+ link: ; rel="first"
+ page-items: '50'
+pagy/extras/headers___pagy_headers_with_Keyset_test_0001_returns_the_full_headers_hash:
+ :headers:
+ link: ; rel="first", ;
rel="next"
- current-page: '1'
page-items: '20'
-pagy/extras/headers___pagy_headers_with_Calendar_test_0003_returns_custom_headers_hash:
+pagy/extras/headers___pagy_headers_merge_with_Calendar_test_0001_returns_the_full_headers_hash:
+ :response: !ruby/hash:Rack::Headers
+ link: ; rel="first", ;
+ rel="prev", ; rel="next", ;
+ rel="last"
+ current-page: '3'
+ page-items: '20'
+ total-pages: '26'
+ total-count: '505'
+pagy/extras/headers___pagy_headers_with_Calendar_test_0002_returns_custom_headers_hash:
:headers:
link: ; rel="first", ;
rel="next", ; rel="last"
+ Per-Page: '20'
+ Total: '505'
pagy/extras/headers___pagy_headers_with_Calendar_test_0006_omit_next_on_last_page:
:headers:
link: ; rel="first", ;
@@ -90,6 +86,12 @@ pagy/extras/headers___pagy_headers_with_Calendar_test_0006_omit_next_on_last_pag
page-items: '20'
total-pages: '26'
total-count: '505'
+pagy/extras/headers___pagy_headers_with_Calendar_test_0004_returns_the_countless_headers_hash:
+ :headers:
+ link: ; rel="first", ;
+ rel="next"
+ current-page: '1'
+ page-items: '20'
pagy/extras/headers___pagy_headers_with_Calendar_test_0001_returns_the_full_headers_hash:
:headers:
link: ; rel="first", ;
@@ -98,12 +100,10 @@ pagy/extras/headers___pagy_headers_with_Calendar_test_0001_returns_the_full_head
page-items: '20'
total-pages: '26'
total-count: '505'
-pagy/extras/headers___pagy_headers_with_Calendar_test_0002_returns_custom_headers_hash:
+pagy/extras/headers___pagy_headers_with_Calendar_test_0003_returns_custom_headers_hash:
:headers:
link: ; rel="first", ;
rel="next", ; rel="last"
- Per-Page: '20'
- Total: '505'
pagy/extras/headers___pagy_headers_with_Calendar_test_0005_omit_prev_on_first_page:
:headers:
link: ; rel="first", ;
diff --git a/test/pagy/extras/js_tools_json_test.rb b/test/pagy/extras/js_tools_calendar_test.rb
similarity index 84%
rename from test/pagy/extras/js_tools_json_test.rb
rename to test/pagy/extras/js_tools_calendar_test.rb
index 58ec51308..f4f000c59 100644
--- a/test/pagy/extras/js_tools_json_test.rb
+++ b/test/pagy/extras/js_tools_calendar_test.rb
@@ -12,11 +12,11 @@
describe 'pagy/extras/js_tools_json' do
let(:app) { MockApp.new(params: {}) }
- describe '#pagy_data' do
- it 'uses json' do
- _(app.pagy_data(Pagy.new(count: 10), :test_function, 'some-string', 123, true)).must_rematch :data
- end
- end
+ # describe '#pagy_data' do
+ # it 'uses json' do
+ # _(app.pagy_data(Pagy.new(count: 10), :test_function, 'some-string', 123, true)).must_rematch :data
+ # end
+ # end
describe 'Calendar sequels and label_sequels' do
it 'generate the labels for the sequels' do
diff --git a/test/pagy/extras/js_tools_json_test.rb.yaml b/test/pagy/extras/js_tools_calendar_test.rb.yaml
similarity index 52%
rename from test/pagy/extras/js_tools_json_test.rb.yaml
rename to test/pagy/extras/js_tools_calendar_test.rb.yaml
index 87e6f5542..bdd6a64a2 100644
--- a/test/pagy/extras/js_tools_json_test.rb.yaml
+++ b/test/pagy/extras/js_tools_calendar_test.rb.yaml
@@ -1,4 +1,35 @@
---
+Calendar_sequels_and_label_sequels_test_0001_generate_the_labels_for_the_sequels:
+ :sequels:
+ '0':
+ - 1
+ - 2
+ - '3'
+ - 4
+ - 5
+ '600':
+ - 1
+ - 2
+ - '3'
+ - 4
+ - 5
+ - 6
+ - 7
+ :label_sequels:
+ '0':
+ - Oct
+ - Nov
+ - Dec
+ - Jan
+ - Feb
+ '600':
+ - Oct
+ - Nov
+ - Dec
+ - Jan
+ - Feb
+ - Mar
+ - Apr
pagy/extras/js_tools_json__Calendar_sequels_and_label_sequels_test_0001_generate_the_labels_for_the_sequels:
:sequels:
'0':
@@ -30,5 +61,3 @@ pagy/extras/js_tools_json__Calendar_sequels_and_label_sequels_test_0001_generate
- Apr
- :gap
- Nov
-pagy/extras/js_tools_json___pagy_data_test_0001_uses_json:
- :data: data-pagy="WyJ0ZXN0X2Z1bmN0aW9uIiwic29tZS1zdHJpbmciLDEyMyx0cnVlXQ=="
diff --git a/test/pagy/extras/js_tools_oj_test.rb b/test/pagy/extras/js_tools_oj_test.rb
deleted file mode 100644
index ee46b28c4..000000000
--- a/test/pagy/extras/js_tools_oj_test.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-require 'oj'
-require_relative '../../test_helper'
-require 'pagy/extras/calendar'
-require 'pagy/extras/js_tools'
-
-require_relative '../../mock_helpers/app'
-
-Time.zone = 'EST'
-Date.beginning_of_week = :sunday
-
-describe 'pagy/extras/js_tools_oj' do
- let(:app) { MockApp.new(params: {}) }
-
- describe '#pagy_data' do
- it 'uses oj' do
- _(app.pagy_data(Pagy.new(count: 10), :test_function, 'some-string', 123, true)).must_rematch :data_1
- _(app.pagy_data(Pagy.new(count: 10, trim_extra: true), :test_function, 'some-string', 123, true)).must_rematch :data_2
- end
- end
-
- describe 'Calendar sequels and label_sequels' do
- it 'generate the labels for the sequels' do
- steps = { 0 => 5, 600 => 7 }
- pagy = Pagy::Calendar.send(:create, :month,
- period: [Time.zone.local(2021, 10, 21, 13, 18, 23, 0),
- Time.zone.local(2023, 11, 13, 15, 43, 40, 0)],
- steps: steps, page: 3)
- _(pagy.sequels).must_rematch :sequels
- _(pagy.label_sequels).must_rematch :label_sequels
- end
- end
-end
diff --git a/test/pagy/extras/js_tools_oj_test.rb.yaml b/test/pagy/extras/js_tools_oj_test.rb.yaml
deleted file mode 100644
index ba7afe5af..000000000
--- a/test/pagy/extras/js_tools_oj_test.rb.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
----
-pagy/extras/js_tools_oj__Calendar_sequels_and_label_sequels_test_0001_generate_the_labels_for_the_sequels:
- :sequels:
- '0':
- - 1
- - 2
- - '3'
- - 4
- - 5
- '600':
- - 1
- - 2
- - '3'
- - 4
- - 5
- - 6
- - 7
- :label_sequels:
- '0':
- - Oct
- - Nov
- - Dec
- - Jan
- - Feb
- '600':
- - Oct
- - Nov
- - Dec
- - Jan
- - Feb
- - Mar
- - Apr
-pagy/extras/js_tools_oj___pagy_data_test_0001_uses_oj:
- :data_1: data-pagy="WyJ0ZXN0X2Z1bmN0aW9uIiwic29tZS1zdHJpbmciLDEyMyx0cnVlXQ=="
- :data_2: data-pagy="WyJ0ZXN0X2Z1bmN0aW9uIiwic29tZS1zdHJpbmciLDEyMyx0cnVlLCJwYWdlIl0="
diff --git a/test/pagy/extras/jsonapi_test.rb b/test/pagy/extras/jsonapi_test.rb
index 0109b0a2d..1a7e20783 100644
--- a/test/pagy/extras/jsonapi_test.rb
+++ b/test/pagy/extras/jsonapi_test.rb
@@ -95,7 +95,7 @@
end
describe '#pagy_jsonapi_links (keyset)' do
it 'returns the ordered links' do
- app = MockApp.new(params: { page: { latest: 'eyJpZCI6MTB9', size: 10 } })
+ app = MockApp.new(params: { page: { latest: 'WzIwXQ', size: 10 } })
pagy, _records = app.send(:pagy_keyset,
Pet.order(:id),
page_param: :latest,
diff --git a/test/pagy/extras/jsonapi_test.rb.yaml b/test/pagy/extras/jsonapi_test.rb.yaml
index 5ada83907..032aa25fa 100644
--- a/test/pagy/extras/jsonapi_test.rb.yaml
+++ b/test/pagy/extras/jsonapi_test.rb.yaml
@@ -1,27 +1,27 @@
---
-pagy/extras/jsonapi___pagy_jsonapi_links_(keyset)_test_0002_sets_the_next_value_to_null_when_the_link_is_unavailable:
+pagy/extras/jsonapi___pagy_jsonapi_links_(keyset)_test_0001_returns_the_ordered_links:
:keyset_result:
- :first: "/foo?page%5Bsize%5D=50&page%5Blatest%5D"
+ :first: "/foo?page%5Blatest%5D&page%5Bsize%5D=10"
:last:
:prev:
- :next:
-pagy/extras/jsonapi___pagy_jsonapi_links_(keyset)_test_0001_returns_the_ordered_links:
+ :next: "/foo?page%5Blatest%5D=WzMwXQ&page%5Bsize%5D=10"
+pagy/extras/jsonapi___pagy_jsonapi_links_(keyset)_test_0002_sets_the_next_value_to_null_when_the_link_is_unavailable:
:keyset_result:
- :first: "/foo?page%5Blatest%5D&page%5Bsize%5D=10"
+ :first: "/foo?page%5Bsize%5D=50&page%5Blatest%5D"
:last:
:prev:
- :next: "/foo?page%5Blatest%5D=eyJpZCI6MjB9&page%5Bsize%5D=10"
+ :next:
+pagy/extras/jsonapi__JsonApi_test_0001_uses_the__jsonapi_with_page_nil:
+ :url_1: "/foo?page%5Bpage%5D=1"
+ :url_2: "/foo?page%5Bpage%5D=1&page%5Blimit%5D=20"
+pagy/extras/jsonapi__JsonApi_test_0002_uses_the__jsonapi_with_page_3:
+ :url_1: "/foo?page%5Bpage%5D=2"
+ :url_2: "/foo?page%5Bpage%5D=2&page%5Blimit%5D=20"
+pagy/extras/jsonapi__JsonApi_with_custom_named_params_test_0002_sets_custom_named_params:
+ :url: "/foo?page%5Bnumber%5D=4&page%5Bsize%5D=10"
pagy/extras/jsonapi___pagy_jsonapi_links_test_0001_returns_the_ordered_links:
:result:
:first: "/foo?page%5Bnumber%5D=1&page%5Bsize%5D=10"
:last: "/foo?page%5Bnumber%5D=100&page%5Bsize%5D=10"
:prev: "/foo?page%5Bnumber%5D=2&page%5Bsize%5D=10"
:next: "/foo?page%5Bnumber%5D=4&page%5Bsize%5D=10"
-pagy/extras/jsonapi__JsonApi_with_custom_named_params_test_0002_sets_custom_named_params:
- :url: "/foo?page%5Bnumber%5D=4&page%5Bsize%5D=10"
-pagy/extras/jsonapi__JsonApi_test_0002_uses_the__jsonapi_with_page_3:
- :url_1: "/foo?page%5Bpage%5D=2"
- :url_2: "/foo?page%5Bpage%5D=2&page%5Blimit%5D=20"
-pagy/extras/jsonapi__JsonApi_test_0001_uses_the__jsonapi_with_page_nil:
- :url_1: "/foo?page%5Bpage%5D=1"
- :url_2: "/foo?page%5Bpage%5D=1&page%5Blimit%5D=20"
diff --git a/test/pagy/extras/keyset_for_ui_test.rb b/test/pagy/extras/keyset_for_ui_test.rb
new file mode 100644
index 000000000..e80beecbf
--- /dev/null
+++ b/test/pagy/extras/keyset_for_ui_test.rb
@@ -0,0 +1,79 @@
+# frozen_string_literal: true
+
+require_relative '../../test_helper'
+require 'pagy/extras/keyset_for_ui'
+require 'pagy/extras/limit'
+
+require_relative '../../files/models'
+require_relative '../../mock_helpers/app'
+
+describe 'pagy/extras/keyset_for_ui' do
+ [Pet, PetSequel].each do |model|
+ describe 'pagy_keyset_for_ui' do
+ # it 'works for page 1' do
+ # app = MockApp.new(params: {})
+ # pagy, records = app.send(:pagy_keyset_for_ui,
+ # model.order(:id),
+ # tuple_comparison: true,
+ # limit: 10)
+ # _(pagy).must_be_kind_of Pagy::KeysetForUI
+ # _(records.size).must_equal 10
+ # _(pagy.next).must_equal 2
+ # _(pagy.update).must_equal [nil, 1, 1, [10]]
+ # end
+ it 'works for page 2' do
+ app = MockApp.new(params: {cutoffs: Pagy::B64.urlsafe_encode(['ppp', 'key', 2, [10]].to_json)},
+ cookie: 'pagy=ppp')
+ pagy, records = app.send(:pagy_keyset_for_ui,
+ model.order(:id),
+ page: 2,
+ tuple_comparison: true,
+ limit: 10)
+ _(pagy).must_be_kind_of Pagy::KeysetForUI
+ _(records.size).must_equal 10
+ _(records.first.id).must_equal 11
+ _(pagy.next).must_equal 3
+ _(pagy.update).must_equal ['key', 2, 1, [20]]
+ end
+ it 'reset pagination for missing cookie' do
+ app = MockApp.new(params: {cutoffs: Pagy::B64.urlsafe_encode(['zzz', 'key', 2, [10]].to_json)},
+ cookie: 'pagy=ppp')
+ pagy, records = app.send(:pagy_keyset_for_ui,
+ model.order(:id),
+ page: 2,
+ tuple_comparison: true,
+ limit: 10)
+ _(pagy).must_be_kind_of Pagy::KeysetForUI
+ _(records.size).must_equal 10
+ _(pagy.next).must_equal 2
+ _(pagy.update).must_equal [nil, 1, 1, [10]]
+ end
+ it 'fallback to Countless if missing cutoffs param' do
+ app = MockApp.new(cookie: 'pagy=ppp')
+ pagy, records = app.send(:pagy_keyset_for_ui,
+ model.order(:id),
+ page: 2,
+ tuple_comparison: true,
+ limit: 10)
+ _(pagy).must_be_kind_of Pagy::Countless
+ _(records.size).must_equal 10
+ _(records.first.id).must_equal 11
+ _(pagy.next).must_equal 3
+ end
+ it 'works for page 5' do
+ app = MockApp.new(params: {cutoffs: Pagy::B64.urlsafe_encode(['ppp', 'key', 5, [40]].to_json)},
+ cookie: 'pagy=ppp')
+ pagy, records = app.send(:pagy_keyset_for_ui,
+ model.order(:id),
+ page: 5,
+ tuple_comparison: true,
+ limit: 10)
+ _(pagy).must_be_kind_of Pagy::KeysetForUI
+ _(records.size).must_equal 10
+ _(records.first.id).must_equal 41
+ _(pagy.next).must_be_nil
+ _(pagy.update).must_equal ['key']
+ end
+ end
+ end
+end
diff --git a/test/pagy/extras/keyset_test.rb b/test/pagy/extras/keyset_test.rb
index 28afb416d..c928b103f 100644
--- a/test/pagy/extras/keyset_test.rb
+++ b/test/pagy/extras/keyset_test.rb
@@ -18,32 +18,32 @@
limit: 10)
_(pagy).must_be_kind_of Pagy::Keyset
_(records.size).must_equal 10
- _(pagy.next).must_equal "eyJhbmltYWwiOiJjYXQiLCJuYW1lIjoiRWxsYSIsImlkIjoxOH0"
+ _(pagy.next).must_equal "WyJjYXQiLCJFbGxhIiwxOF0"
end
it 'pulls the page from params' do
- app = MockApp.new(params: { page: "eyJpZCI6MTB9", limit: 10 })
+ app = MockApp.new(params: { page: "WzEwXQ", limit: 10 })
pagy, records = app.send(:pagy_keyset,
model.order(:id),
tuple_comparison: true)
_(records.first.id).must_equal 11
- _(pagy.next).must_equal "eyJpZCI6MjB9"
+ _(pagy.next).must_equal "WzIwXQ"
end
end
describe 'URL helpers' do
it 'returns the URLs for first page' do
- app = MockApp.new(params: { page: "eyJpZCI6MTB9", limit: 10 })
+ app = MockApp.new(params: { page: nil, limit: 10 })
pagy, _records = app.send(:pagy_keyset, model.order(:id))
_(app.send(:pagy_keyset_first_url, pagy)).must_equal "/foo?page&limit=10"
- _(app.send(:pagy_keyset_next_url, pagy)).must_equal "/foo?page=eyJpZCI6MjB9&limit=10"
+ _(app.send(:pagy_keyset_next_url, pagy)).must_equal "/foo?page=WzEwXQ&limit=10"
end
it 'returns the URLs for second page' do
- app = MockApp.new(params: { page: "eyJpZCI6MjB9", limit: 10 })
+ app = MockApp.new(params: { page: "WzEwXQ", limit: 10 })
pagy, _records = app.send(:pagy_keyset, model.order(:id))
_(app.send(:pagy_keyset_first_url, pagy)).must_equal "/foo?page&limit=10"
- _(app.send(:pagy_keyset_next_url, pagy)).must_equal "/foo?page=eyJpZCI6MzB9&limit=10"
+ _(app.send(:pagy_keyset_next_url, pagy)).must_equal "/foo?page=WzIwXQ&limit=10"
end
it 'returns the URLs for last page' do
- app = MockApp.new(params: { page: "eyJpZCI6NDB9", limit: 10 })
+ app = MockApp.new(params: { page: "WzQwXQ", limit: 10 })
pagy, _records = app.send(:pagy_keyset, model.order(:id))
_(app.send(:pagy_keyset_first_url, pagy)).must_equal "/foo?page&limit=10"
_(app.send(:pagy_keyset_next_url, pagy)).must_be_nil
diff --git a/test/pagy/extras/limit_test.rb b/test/pagy/extras/limit_test.rb
index d072f9e7b..8599ee66e 100644
--- a/test/pagy/extras/limit_test.rb
+++ b/test/pagy/extras/limit_test.rb
@@ -16,7 +16,7 @@
def test_limit_vars_params(limit, vars, params)
app = MockApp.new params: params
- _(app.params.to_options).must_equal params
+ _(app.params.to_param).must_equal params.to_param
[[:pagy_elasticsearch_rails, MockElasticsearchRails::Model],
[:pagy_searchkick, MockSearchkick::Model]].each do |meth, mod|
pagy, records = app.send(meth, mod.pagy_search('a').records, **vars)
diff --git a/test/pagy/extras/limit_test.rb.yaml b/test/pagy/extras/limit_test.rb.yaml
index 118633fe8..829b91c4c 100644
--- a/test/pagy/extras/limit_test.rb.yaml
+++ b/test/pagy/extras/limit_test.rb.yaml
@@ -1,10 +1,10 @@
---
pagy/extras/limit__view_methods_test_0001_renders_limit_selector:
- :selector_1: '