Centralize per page checking
I need to create some new UserPreference helper methods - min_per_page
, max_per_page
, and valid_per_page
(and their associated self.
methods). The reason for this is a bug I discovered that allowed a user to use incorrect per_page
values if they were in the range [10, 1000] when casted to an int (that is, a user could specify 1000.7 and it would be silently casted to 1000). This occurred everywhere a per_page
was used, but only affected reports and search views because chat logs had a separate advanced search form, rather than being inlined.
The min_per_page
method would return 10, max_per_page
1000, and valid_per_page
would return True or False. I will need to find everywhere I check per_page
values in the application and use this helper method (I need to check controllers and concerns, and views which likely have hardcoded 10 and 1000 values).
-
Create new helper methods -
Adjust helper methods, concerns, models, and controllers to use new methods -
Modify views to use these values