diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-05-11 13:36:38 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-05-11 13:36:38 +1100 |
commit | 0e9297b37ae950eb9e2cd08aa6c43cfd5ecfc646 (patch) | |
tree | 7303a7c562e8a6d3d7ad59a13a54fc5f079f9677 | |
parent | 35816eb7be76aa1a26dcf2f9cfeddf7c60b2da26 (diff) | |
download | gitlab-ce-0e9297b37ae950eb9e2cd08aa6c43cfd5ecfc646.tar.gz |
[Rails5] Fix `per_page` in lib/gitlab/multi_collection_paginator.rb46233-rails5-fix-nomethoderror-undefined-method-for-3-string
In Rails 5 the `per_page` argument came from `params` is String but an
Integer is expected.
This commit explicitly converts `per_page` to an Integer.
It fixes the errors like:
```
1) Groups::ChildrenController GET #index for subgroups filtering children succeeds if multiple pages contain matching subgroups
Failure/Error:
hash[page] = second_collection.page(second_collection_page)
.per(per_page - paginated_first_collection(page).size)
.padding(offset)
NoMethodError:
undefined method `-' for "3":String
Did you mean? -@
# ./lib/gitlab/multi_collection_paginator.rb:42:in `block in paginated_second_collection'
# ./lib/gitlab/multi_collection_paginator.rb:46:in `paginated_second_collection'
# ./lib/gitlab/multi_collection_paginator.rb:14:in `paginate'
# ./app/finders/group_descendants_finder.rb:52:in `children'
# ./app/finders/group_descendants_finder.rb:34:in `execute'
# ./app/controllers/groups/children_controller.rb:36:in `setup_children'
# ./app/controllers/groups/children_controller.rb:18:in `index'
# ./lib/gitlab/i18n.rb:50:in `with_locale'
# ./lib/gitlab/i18n.rb:56:in `with_user_locale'
# ./app/controllers/application_controller.rb:351:in `set_locale'
# ./spec/controllers/groups/children_controller_spec.rb:182:in `block (5 levels) in <top (required)>'
# ./spec/spec_helper.rb:198:in `block (2 levels) in <top (required)>'
```
-rw-r--r-- | lib/gitlab/multi_collection_paginator.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/gitlab/multi_collection_paginator.rb b/lib/gitlab/multi_collection_paginator.rb index 43921a8c1c0..fd5de73c526 100644 --- a/lib/gitlab/multi_collection_paginator.rb +++ b/lib/gitlab/multi_collection_paginator.rb @@ -5,7 +5,7 @@ module Gitlab def initialize(*collections, per_page: nil) raise ArgumentError.new('Only 2 collections are supported') if collections.size != 2 - @per_page = per_page || Kaminari.config.default_per_page + @per_page = (per_page || Kaminari.config.default_per_page).to_i @first_collection, @second_collection = collections end |