File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,14 @@ def self.init!
18
18
require 'grape/pagination'
19
19
Grape ::API . send ( :include , Grape ::Pagination )
20
20
end
21
+
21
22
# Kaminari and will_paginate conflict with each other, so we should check
22
23
# to see if either is already active before attempting to load them.
23
24
if defined? ( Kaminari ) && defined? ( WillPaginate ::CollectionMethods )
24
25
STDERR . puts <<-EOC
25
- Warning: api-pagination relies on either Kaminari or WillPaginate, but these
26
- gems conflict. Please ensure only one of them is active at any given time.
26
+ Warning: api-pagination relies on either Kaminari or WillPaginate, but these
27
+ gems conflict. Please ensure only one of them is active at any given time.
28
+
27
29
EOC
28
30
return
29
31
elsif defined? ( Kaminari )
@@ -57,6 +59,7 @@ def self.init!
57
59
end
58
60
59
61
def self . initialize_kaminari!
62
+ require 'kaminari/models/array_extension'
60
63
ApiPagination . instance_variable_set ( :@paginator , :kaminari )
61
64
end
62
65
@@ -71,8 +74,4 @@ def last_page?() !next_page end
71
74
end
72
75
end
73
76
74
- if ENV [ 'PAGINATOR' ]
75
- ApiPagination . instance_variable_set ( :@paginator , ENV [ 'PAGINATOR' ] . to_sym )
76
- end
77
-
78
77
ApiPagination ::Hooks . init!
Original file line number Diff line number Diff line change 1
- require 'support/numbers_controller'
2
- require 'support/numbers_api'
3
- require 'api-pagination'
4
-
5
1
if ENV [ 'PAGINATOR' ]
6
2
ApiPagination . instance_variable_set ( :@paginator , ENV [ 'PAGINATOR' ] . to_sym )
7
3
else
8
4
warn 'No PAGINATOR set. Defaulting to kaminari. To test against will_paginate, run `PAGINATOR=will_paginate bundle exec rspec`'
9
5
ApiPagination . instance_variable_set ( :@paginator , :kaminari )
10
6
end
11
7
12
- if ApiPagination . paginator == :kaminari
13
- Kaminari :: Hooks . init
14
- elsif ApiPagination . paginator == :will_paginate
15
- require 'will_paginate/array'
16
- end
8
+ require 'support/numbers_controller'
9
+ require 'support/numbers_api'
10
+ require 'api-pagination'
11
+
12
+ require 'will_paginate/array' if ApiPagination . paginator == :will_paginate
17
13
18
14
RSpec . configure do |config |
19
15
config . include Rack ::Test ::Methods
You can’t perform that action at this time.
0 commit comments