kaminari 0.16.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kaminari might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +21 -11
- data/CHANGELOG.rdoc +23 -0
- data/README.rdoc +2 -2
- data/Rakefile +2 -2
- data/gemfiles/active_record_31.gemfile +3 -0
- data/gemfiles/active_record_32.gemfile +3 -0
- data/gemfiles/active_record_40.gemfile +1 -0
- data/gemfiles/active_record_42.gemfile +24 -0
- data/gemfiles/data_mapper_12.gemfile +5 -1
- data/gemfiles/mongo_mapper.gemfile +11 -5
- data/gemfiles/mongoid_24.gemfile +4 -0
- data/gemfiles/mongoid_30.gemfile +4 -0
- data/gemfiles/mongoid_31.gemfile +4 -0
- data/gemfiles/mongoid_40.gemfile +4 -0
- data/gemfiles/sinatra_13.gemfile +20 -11
- data/gemfiles/sinatra_14.gemfile +5 -1
- data/lib/generators/kaminari/views_generator.rb +6 -5
- data/lib/kaminari/helpers/action_view_extension.rb +3 -1
- data/lib/kaminari/helpers/paginator.rb +0 -1
- data/lib/kaminari/helpers/sinatra_helpers.rb +1 -0
- data/lib/kaminari/models/active_record_model_extension.rb +1 -1
- data/lib/kaminari/models/active_record_relation_methods.rb +5 -0
- data/lib/kaminari/models/array_extension.rb +8 -4
- data/lib/kaminari/models/mongoid_criteria_methods.rb +5 -0
- data/lib/kaminari/models/mongoid_extension.rb +9 -3
- data/lib/kaminari/version.rb +1 -1
- data/spec/fake_app/active_record/models.rb +1 -1
- data/spec/fake_app/mongo_mapper/config.rb +1 -1
- data/spec/fake_app/mongoid/config.rb +2 -2
- data/spec/fake_app/mongoid/models.rb +9 -1
- data/spec/helpers/action_view_extension_spec.rb +5 -0
- data/spec/models/active_record/active_record_relation_methods_spec.rb +6 -0
- data/spec/models/array_spec.rb +8 -5
- data/spec/models/mongoid/mongoid_spec.rb +26 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2627d8c87c7ace1ca82760c49c31f7cd7cc0dc3b
|
4
|
+
data.tar.gz: e8f5c196e7e5a01ad32579f7b3157912b6f2fe9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cc0e4d37b650625b17c42545cfe6ffb71a7e716a0a7b28bb29330ee506d99a5b4bb820c8cc9ea1ea4379ce45cc00c93772e3d3e966b2808d827e5c5582b006a
|
7
|
+
data.tar.gz: 26bcfb07c7a0ea59728afd2e140683a66c350687fd96ac40f015530008b1700c1410d481bb25aa935cd6c60c37629105ddb201841432de43cad436f913c006b3
|
data/.travis.yml
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
script: "bundle exec rake spec"
|
1
|
+
language: ruby
|
4
2
|
|
5
3
|
rvm:
|
6
4
|
- 1.8.7
|
7
5
|
- 1.9.3
|
8
6
|
- 2.0.0
|
9
7
|
- 2.1
|
10
|
-
-
|
8
|
+
- 2.2
|
11
9
|
- jruby
|
12
10
|
- rbx-2
|
13
11
|
|
@@ -17,7 +15,7 @@ gemfile:
|
|
17
15
|
- gemfiles/active_record_32.gemfile
|
18
16
|
- gemfiles/active_record_40.gemfile
|
19
17
|
- gemfiles/active_record_41.gemfile
|
20
|
-
- gemfiles/
|
18
|
+
- gemfiles/active_record_42.gemfile
|
21
19
|
- gemfiles/data_mapper_12.gemfile
|
22
20
|
- gemfiles/mongo_mapper.gemfile
|
23
21
|
- gemfiles/mongoid_24.gemfile
|
@@ -27,6 +25,14 @@ gemfile:
|
|
27
25
|
- gemfiles/sinatra_13.gemfile
|
28
26
|
- gemfiles/sinatra_14.gemfile
|
29
27
|
|
28
|
+
sudo: false
|
29
|
+
|
30
|
+
services: mongodb
|
31
|
+
|
32
|
+
script: "bundle exec rake spec"
|
33
|
+
|
34
|
+
cache: bundler
|
35
|
+
|
30
36
|
matrix:
|
31
37
|
exclude:
|
32
38
|
- rvm: 1.8.7
|
@@ -34,20 +40,24 @@ matrix:
|
|
34
40
|
- rvm: 1.8.7
|
35
41
|
gemfile: gemfiles/active_record_41.gemfile
|
36
42
|
- rvm: 1.8.7
|
37
|
-
gemfile: gemfiles/
|
43
|
+
gemfile: gemfiles/active_record_42.gemfile
|
38
44
|
- rvm: 1.8.7
|
39
45
|
gemfile: gemfiles/mongoid_30.gemfile
|
40
46
|
- rvm: 1.8.7
|
41
47
|
gemfile: gemfiles/mongoid_31.gemfile
|
42
48
|
- rvm: 1.8.7
|
43
49
|
gemfile: gemfiles/mongoid_40.gemfile
|
44
|
-
- rvm:
|
50
|
+
- rvm: 2.2
|
45
51
|
gemfile: gemfiles/active_record_30.gemfile
|
46
|
-
- rvm:
|
52
|
+
- rvm: 2.2
|
47
53
|
gemfile: gemfiles/active_record_31.gemfile
|
48
|
-
- rvm:
|
54
|
+
- rvm: 2.2
|
49
55
|
gemfile: gemfiles/active_record_32.gemfile
|
56
|
+
- rvm: 2.2
|
57
|
+
gemfile: gemfiles/mongoid_24.gemfile
|
50
58
|
allow_failures:
|
51
|
-
- rvm:
|
52
|
-
|
59
|
+
- rvm: 1.8.7
|
60
|
+
gemfile: gemfiles/mongoid_24.gemfile
|
61
|
+
- rvm: jruby
|
62
|
+
- rvm: rbx-2
|
53
63
|
fast_finish: true
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
== 0.16.2
|
2
|
+
|
3
|
+
* Fixed a bug where cloned Relations remember previous relations'
|
4
|
+
@total_count value #565 [inkstak]
|
5
|
+
|
6
|
+
* Fixed a bug where `paginate_array()` with total_count option returns whole
|
7
|
+
array for every page #516 [abhichvn]
|
8
|
+
|
9
|
+
* Fixed a bug where :num_pages option was backwards-incompatible #605
|
10
|
+
[klebershimabuku]
|
11
|
+
|
12
|
+
* Fixed a bug where themed views generator attempts to overwrite README.md
|
13
|
+
#623 [swrobel]
|
14
|
+
|
15
|
+
* Fixed a bug that ruby raises a NameError when theme was not found #622
|
16
|
+
[maxprokopiev]
|
17
|
+
|
18
|
+
* Fixed a bug that paginates_per does not work with subclasses on mongoid #634
|
19
|
+
[kouyaf77]
|
20
|
+
|
21
|
+
* Show an error message if a proper template was not found for the generator
|
22
|
+
theme #600 [meltedice]
|
23
|
+
|
1
24
|
== 0.16.1
|
2
25
|
|
3
26
|
* Fix a bug where :theme option for #paginate method doesn't work properly
|
data/README.rdoc
CHANGED
@@ -27,9 +27,9 @@ The pagination helper outputs the HTML5 <nav> tag by default. Plus, the helper s
|
|
27
27
|
|
28
28
|
== Supported versions
|
29
29
|
|
30
|
-
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.
|
30
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.x, 2.2.x
|
31
31
|
|
32
|
-
* Rails 3.0, 3.1, 3.2, 4.0, 4.1
|
32
|
+
* Rails 3.0, 3.1, 3.2, 4.0, 4.1, 4.2
|
33
33
|
|
34
34
|
* Haml 3+
|
35
35
|
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
task :default => "spec:all"
|
14
14
|
|
15
15
|
namespace :spec do
|
16
|
-
%w(active_record_edge active_record_40 active_record_41 active_record_32 active_record_31 active_record_30 data_mapper_12 mongoid_40 mongoid_31 mongoid_30 mongoid_24 mongo_mapper sinatra_13 sinatra_14).each do |gemfile|
|
16
|
+
%w(active_record_edge active_record_40 active_record_41 active_record_42 active_record_32 active_record_31 active_record_30 data_mapper_12 mongoid_40 mongoid_31 mongoid_30 mongoid_24 mongo_mapper sinatra_13 sinatra_14).each do |gemfile|
|
17
17
|
desc "Run Tests against #{gemfile}"
|
18
18
|
task gemfile do
|
19
19
|
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
|
@@ -23,7 +23,7 @@ namespace :spec do
|
|
23
23
|
|
24
24
|
desc "Run Tests against all ORMs"
|
25
25
|
task :all do
|
26
|
-
%w(active_record_edge active_record_40 active_record_41 active_record_32 active_record_31 active_record_30 data_mapper_12 mongoid_40 mongoid_31 mongoid_30 mongoid_24 mongo_mapper sinatra_13 sinatra_14).each do |gemfile|
|
26
|
+
%w(active_record_edge active_record_40 active_record_41 active_record_42 active_record_32 active_record_31 active_record_30 data_mapper_12 mongoid_40 mongoid_31 mongoid_30 mongoid_24 mongo_mapper sinatra_13 sinatra_14).each do |gemfile|
|
27
27
|
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
|
28
28
|
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
|
29
29
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'railties', '~> 4.2.0'
|
4
|
+
gem 'activerecord', '~> 4.2.0', :require => 'active_record'
|
5
|
+
gem 'rspec-rails', '~> 2.14.1'
|
6
|
+
|
7
|
+
platforms :ruby do
|
8
|
+
if RUBY_VERSION > "2.1.0"
|
9
|
+
gem 'sqlite3'
|
10
|
+
else
|
11
|
+
gem 'sqlite3', '1.3.8'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
platforms :jruby do
|
15
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
16
|
+
end
|
17
|
+
platforms :rbx do
|
18
|
+
gem 'rubysl', '~> 2.0'
|
19
|
+
gem 'racc'
|
20
|
+
gem 'minitest'
|
21
|
+
gem 'rubinius-developer_tools'
|
22
|
+
end
|
23
|
+
|
24
|
+
gemspec :path => '../'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'railties', '
|
3
|
+
gem 'railties', '~> 3.2.21'
|
4
4
|
gem 'dm-core', '~> 1.2.0'
|
5
5
|
gem 'dm-migrations', '~> 1.2.0'
|
6
6
|
gem 'dm-aggregates', '~> 1.2.0'
|
@@ -18,9 +18,13 @@ gem 'mime-types', '< 2'
|
|
18
18
|
platforms :ruby do
|
19
19
|
if RUBY_VERSION > "2.1.0"
|
20
20
|
gem 'sqlite3'
|
21
|
+
gem 'test-unit'
|
21
22
|
else
|
22
23
|
gem 'sqlite3', '1.3.8'
|
23
24
|
end
|
25
|
+
if RUBY_VERSION <= "1.8.7"
|
26
|
+
gem 'i18n', '< 0.7.0'
|
27
|
+
end
|
24
28
|
end
|
25
29
|
platforms :jruby do
|
26
30
|
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.2.0'
|
@@ -6,13 +6,19 @@ gem 'mongo_mapper', '>= 0.11.0'
|
|
6
6
|
gem 'rspec-rails', '~> 2.14.1'
|
7
7
|
|
8
8
|
# stick to versions that work under Ruby 1.8 for now
|
9
|
-
gem 'capybara', '< 2.1'
|
10
|
-
gem 'nokogiri', '< 1.6'
|
11
|
-
gem 'rubyzip', '< 1'
|
12
|
-
gem 'mime-types', '< 2'
|
13
|
-
|
14
9
|
if RUBY_VERSION == '1.8.7'
|
10
|
+
gem 'capybara', '< 2.1'
|
11
|
+
gem 'nokogiri', '< 1.6'
|
12
|
+
gem 'rubyzip', '< 1'
|
13
|
+
gem 'mime-types', '< 2'
|
14
|
+
|
15
15
|
gem 'activesupport', '~> 3.2.18'
|
16
|
+
gem 'i18n', '< 0.7.0'
|
17
|
+
else
|
18
|
+
gem 'capybara'
|
19
|
+
gem 'nokogiri'
|
20
|
+
gem 'rubyzip'
|
21
|
+
gem 'mime-types'
|
16
22
|
end
|
17
23
|
|
18
24
|
platforms :rbx do
|
data/gemfiles/mongoid_24.gemfile
CHANGED
data/gemfiles/mongoid_30.gemfile
CHANGED
data/gemfiles/mongoid_31.gemfile
CHANGED
data/gemfiles/mongoid_40.gemfile
CHANGED
data/gemfiles/sinatra_13.gemfile
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'activerecord', '~> 3.2.3', :require => 'active_record'
|
4
3
|
gem 'sinatra', '~> 1.3.0'
|
5
|
-
gem 'tilt'
|
6
|
-
gem 'padrino-helpers', '~> 0.10.6'
|
7
|
-
gem 'rack-test', '>= 0'
|
8
|
-
gem 'sinatra-contrib', '~> 1.3.0'
|
9
|
-
gem 'rspec', '~> 2.14.1'
|
4
|
+
gem 'tilt'
|
10
5
|
|
11
|
-
|
12
|
-
gem '
|
13
|
-
gem '
|
14
|
-
|
15
|
-
gem '
|
6
|
+
if RUBY_VERSION >= "2.2.0"
|
7
|
+
gem 'activerecord', '>= 4.0.0', :require => 'active_record'
|
8
|
+
gem 'padrino-helpers'
|
9
|
+
else
|
10
|
+
gem 'activerecord', '~> 3.2.3', :require => 'active_record'
|
11
|
+
gem 'padrino-helpers', '~> 0.10.6'
|
12
|
+
end
|
13
|
+
|
14
|
+
gem 'rack-test'
|
15
|
+
gem 'sinatra-contrib'
|
16
|
+
gem 'rspec', '~> 2.14.1'
|
16
17
|
|
17
18
|
platforms :ruby do
|
18
19
|
if RUBY_VERSION > "2.1.0"
|
@@ -20,6 +21,14 @@ platforms :ruby do
|
|
20
21
|
else
|
21
22
|
gem 'sqlite3', '1.3.8'
|
22
23
|
end
|
24
|
+
if RUBY_VERSION <= "1.8.7"
|
25
|
+
# stick to versions that work under Ruby 1.8 for now
|
26
|
+
gem 'mime-types', '< 2.0'
|
27
|
+
gem 'nokogiri', '< 1.6'
|
28
|
+
gem 'capybara', '< 2.1'
|
29
|
+
gem 'rubyzip', '< 1'
|
30
|
+
gem 'i18n', '< 0.7.0'
|
31
|
+
end
|
23
32
|
end
|
24
33
|
platforms :jruby do
|
25
34
|
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
data/gemfiles/sinatra_14.gemfile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'activerecord', '~> 3.2.0', :require => 'active_record'
|
4
3
|
gem 'sinatra', '~> 1.4.0'
|
5
4
|
gem 'rspec', '~> 2.14.1'
|
6
5
|
|
7
6
|
if RUBY_VERSION <= "1.8.7"
|
7
|
+
gem 'activerecord', '~> 3.2.0', :require => 'active_record'
|
8
8
|
gem 'padrino-helpers', '~> 0.11.0'
|
9
9
|
else
|
10
|
+
gem 'activerecord', '>= 4.0.0', :require => 'active_record'
|
10
11
|
gem 'padrino-helpers', '~> 0.12.0'
|
11
12
|
end
|
12
13
|
|
@@ -25,6 +26,9 @@ platforms :ruby do
|
|
25
26
|
else
|
26
27
|
gem 'sqlite3', '1.3.8'
|
27
28
|
end
|
29
|
+
if RUBY_VERSION <= "1.8.7"
|
30
|
+
gem 'i18n', '< 0.7.0'
|
31
|
+
end
|
28
32
|
end
|
29
33
|
platforms :jruby do
|
30
34
|
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
@@ -24,11 +24,12 @@ BANNER
|
|
24
24
|
def copy_or_fetch #:nodoc:
|
25
25
|
return copy_default_views if file_name == 'default'
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
if theme = self.class.themes.detect {|t| t.name == file_name}
|
28
|
+
if download_templates(theme).empty?
|
29
|
+
say %Q[template_engine: #{template_engine} is not available for theme: #{file_name}]
|
30
|
+
end
|
30
31
|
else
|
31
|
-
say %Q[no such theme: #{file_name}\n avaliable themes: #{themes.map(&:name).join ", "}]
|
32
|
+
say %Q[no such theme: #{file_name}\n avaliable themes: #{self.class.themes.map(&:name).join ", "}]
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -89,7 +90,7 @@ BANNER
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def templates_for(template_engine) #:nodoc:
|
92
|
-
@templates.select {|t|
|
93
|
+
@templates.select {|t| t.engine == template_engine }
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
@@ -15,7 +15,9 @@ module Kaminari
|
|
15
15
|
# * <tt>:remote</tt> - Ajax? (false by default)
|
16
16
|
# * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
|
17
17
|
def paginate(scope, options = {}, &block)
|
18
|
-
|
18
|
+
options[:total_pages] ||= options[:num_pages] || scope.total_pages
|
19
|
+
|
20
|
+
paginator = Kaminari::Helpers::Paginator.new(self, options.reverse_merge(:current_page => scope.current_page, :per_page => scope.limit_value, :remote => false))
|
19
21
|
paginator.to_s
|
20
22
|
end
|
21
23
|
|
@@ -13,7 +13,6 @@ module Kaminari
|
|
13
13
|
|
14
14
|
def initialize(template, options) #:nodoc:
|
15
15
|
#FIXME for compatibility. remove num_pages at some time in the future
|
16
|
-
options[:total_pages] ||= options[:num_pages]
|
17
16
|
options[:num_pages] ||= options[:total_pages]
|
18
17
|
|
19
18
|
@window_options = {}.tap do |h|
|
@@ -11,7 +11,7 @@ module Kaminari
|
|
11
11
|
# Model.page(5)
|
12
12
|
eval <<-RUBY
|
13
13
|
def self.#{Kaminari.config.page_method_name}(num = nil)
|
14
|
-
limit(default_per_page).offset(default_per_page * (
|
14
|
+
limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num)).extending do
|
15
15
|
include Kaminari::ActiveRecordRelationMethods
|
16
16
|
include Kaminari::PageScopeMethods
|
17
17
|
end
|
@@ -12,6 +12,11 @@ module Kaminari
|
|
12
12
|
model_name.human.downcase
|
13
13
|
end
|
14
14
|
|
15
|
+
def reset #:nodoc:
|
16
|
+
@total_count = nil
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
15
20
|
def total_count(column_name = :all, options = {}) #:nodoc:
|
16
21
|
# #count overrides the #select which could include generated columns referenced in #order, so skip #order here, where it's irrelevant to the result anyway
|
17
22
|
@total_count ||= begin
|
@@ -17,11 +17,15 @@ module Kaminari
|
|
17
17
|
extend Kaminari::PageScopeMethods
|
18
18
|
end
|
19
19
|
|
20
|
-
if @_total_count
|
21
|
-
original_array = original_array.first(@_total_count)
|
20
|
+
if @_total_count.present? && @_total_count <= original_array.count
|
21
|
+
original_array = original_array.first(@_total_count)[@_offset_value, @_limit_value]
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
if @_total_count.nil?
|
25
|
+
original_array = original_array[@_offset_value, @_limit_value]
|
26
|
+
end
|
27
|
+
|
28
|
+
super(original_array || [])
|
25
29
|
end
|
26
30
|
|
27
31
|
def entry_name
|
@@ -31,7 +35,7 @@ module Kaminari
|
|
31
35
|
# items at the specified "page"
|
32
36
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
33
37
|
def #{Kaminari.config.page_method_name}(num = 1)
|
34
|
-
offset(limit_value * (
|
38
|
+
offset(limit_value * ((num = num.to_i - 1) < 0 ? 0 : num))
|
35
39
|
end
|
36
40
|
RUBY
|
37
41
|
|
@@ -7,14 +7,20 @@ module Kaminari
|
|
7
7
|
include Kaminari::ConfigurationMethods
|
8
8
|
|
9
9
|
included do
|
10
|
-
# Fetch the values at the specified page number
|
11
|
-
# Model.page(5)
|
12
10
|
scope Kaminari.config.page_method_name, Proc.new {|num|
|
13
|
-
limit(default_per_page).offset(default_per_page * (
|
11
|
+
limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num))
|
14
12
|
} do
|
15
13
|
include Kaminari::MongoidCriteriaMethods
|
16
14
|
include Kaminari::PageScopeMethods
|
17
15
|
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def inherited_with_kaminari(kls)
|
19
|
+
inherited_without_kaminari(kls)
|
20
|
+
kls.send(:include, Kaminari::MongoidExtension::Document.dup)
|
21
|
+
end
|
22
|
+
alias_method_chain :inherited, :kaminari
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/kaminari/version.rb
CHANGED
@@ -10,7 +10,7 @@ class User < ActiveRecord::Base
|
|
10
10
|
User.joins(:books_read => :authors).where(:authors_books => {:id => self})
|
11
11
|
end
|
12
12
|
|
13
|
-
scope :by_name, order(:name)
|
13
|
+
scope :by_name, lambda { order(:name) }
|
14
14
|
scope :by_read_count, lambda {
|
15
15
|
cols = if connection.adapter_name == "PostgreSQL"
|
16
16
|
column_names.map { |column| %{"users"."#{column}"} }.join(", ")
|
@@ -1,2 +1,2 @@
|
|
1
|
-
MongoMapper.connection = Mongo::Connection.new '
|
1
|
+
MongoMapper.connection = Mongo::Connection.new '0.0.0.0', 27017
|
2
2
|
MongoMapper.database = 'kaminari_test'
|
@@ -5,13 +5,13 @@
|
|
5
5
|
# See: http://redmine.ruby-lang.org/issues/show/4300
|
6
6
|
require 'mongoid/version'
|
7
7
|
|
8
|
-
if RUBY_VERSION >= '1.9.2'
|
8
|
+
if RUBY_VERSION >= '1.9.2' && RUBY_VERSION < '2.2.0'
|
9
9
|
YAML::ENGINE.yamler = 'syck'
|
10
10
|
end
|
11
11
|
|
12
12
|
Mongoid.configure do |config|
|
13
13
|
if Mongoid::VERSION > '3.0.0'
|
14
|
-
config.sessions = {:default => {:hosts => ['
|
14
|
+
config.sessions = {:default => {:hosts => ['0.0.0.0:27017'], :database => 'kaminari_test'}}
|
15
15
|
else
|
16
16
|
config.master = Mongo::Connection.new.db('kaminari_test')
|
17
17
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class User
|
2
2
|
include ::Mongoid::Document
|
3
|
-
if Mongoid::VERSION
|
3
|
+
if Mongoid::VERSION >= '4.0.0'
|
4
4
|
include Mongoid::Attributes::Dynamic
|
5
5
|
end
|
6
6
|
|
@@ -12,6 +12,14 @@ class User::Address
|
|
12
12
|
include ::Mongoid::Document
|
13
13
|
end
|
14
14
|
|
15
|
+
class Product
|
16
|
+
include ::Mongoid::Document
|
17
|
+
end
|
18
|
+
|
19
|
+
class Device < Product
|
20
|
+
paginates_per 100
|
21
|
+
end
|
22
|
+
|
15
23
|
class MongoMongoidExtensionDeveloper
|
16
24
|
include ::Mongoid::Document
|
17
25
|
field :salary, :type => Integer
|
@@ -28,6 +28,11 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails)do
|
|
28
28
|
subject { helper.paginate @users, :views_prefix => "alternative/", :params => {:controller => 'users', :action => 'index'} }
|
29
29
|
it { should eq(" <b>1</b>\n") }
|
30
30
|
end
|
31
|
+
|
32
|
+
context "num_pages: 3" do
|
33
|
+
subject { helper.paginate @users, :num_pages => 3, :params => {:controller => 'users', :action => 'index'} }
|
34
|
+
it { should match(/<a href="\/users\?page=3">Last/) }
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
describe '#link_to_previous_page' do
|
@@ -14,6 +14,12 @@ if defined? ActiveRecord
|
|
14
14
|
@books.each {|book| book.readers << @readers }
|
15
15
|
end
|
16
16
|
|
17
|
+
context "when the scope is cloned" do
|
18
|
+
it "should reset total_coount momoization" do
|
19
|
+
User.page.tap(&:total_count).where(:name => 'author').total_count.should == 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
context "when the scope includes an order which references a generated column" do
|
18
24
|
it "should successfully count the results" do
|
19
25
|
@author.readers.by_read_count.page(1).total_count.should == @readers.size
|
data/spec/models/array_spec.rb
CHANGED
@@ -142,27 +142,30 @@ describe Kaminari::PaginatableArray do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
context 'when setting total count explicitly' do
|
145
|
-
context "
|
145
|
+
context "array 1..10, page 5, per 10, total_count 9999" do
|
146
146
|
subject { Kaminari::PaginatableArray.new((1..10).to_a, :total_count => 9999).page(5).per(10) }
|
147
147
|
|
148
|
-
it { should have(
|
149
|
-
its(:first) { should
|
148
|
+
it { should have(10).items }
|
149
|
+
its(:first) { should == 1 }
|
150
|
+
its(:current_page) { should == 5 }
|
150
151
|
its(:total_count) { should == 9999 }
|
151
152
|
end
|
152
153
|
|
153
|
-
context "
|
154
|
+
context "array 1..15, page 1, per 10, total_count 15" do
|
154
155
|
subject { Kaminari.paginate_array((1..15).to_a, :total_count => 15).page(1).per(10) }
|
155
156
|
|
156
157
|
it { should have(10).items }
|
157
158
|
its(:first) { should == 1 }
|
159
|
+
its(:current_page) { should == 1 }
|
158
160
|
its(:total_count) { should == 15 }
|
159
161
|
end
|
160
162
|
|
161
|
-
context "
|
163
|
+
context "array 1..25, page 2, per 10, total_count 15" do
|
162
164
|
subject { Kaminari.paginate_array((1..25).to_a, :total_count => 15).page(2).per(10) }
|
163
165
|
|
164
166
|
it { should have(5).items }
|
165
167
|
its(:first) { should == 11 }
|
168
|
+
its(:current_page) { should == 2 }
|
166
169
|
its(:total_count) { should == 15 }
|
167
170
|
end
|
168
171
|
end
|
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
if defined? Mongoid
|
4
|
+
describe Kaminari::MongoidCriteriaMethods do
|
5
|
+
describe "#total_count" do
|
6
|
+
before do
|
7
|
+
2.times {|i| User.create!(:salary => i) }
|
8
|
+
end
|
9
|
+
|
10
|
+
context "when the scope is cloned" do
|
11
|
+
it "should reset total_coount momoization" do
|
12
|
+
User.page.tap(&:total_count).where(:salary => 1).total_count.should == 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
describe Kaminari::MongoidExtension do
|
5
19
|
before(:each) do
|
6
20
|
41.times do
|
@@ -193,5 +207,17 @@ if defined? Mongoid
|
|
193
207
|
its(:total_pages) { should == 2 }
|
194
208
|
end
|
195
209
|
end
|
210
|
+
|
211
|
+
describe '#paginates_per' do
|
212
|
+
context 'when paginates_per is not defined in superclass' do
|
213
|
+
subject { Product.all.page 1 }
|
214
|
+
its(:limit_value) { should == 25 }
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'when paginates_per is defined in subclass' do
|
218
|
+
subject { Device.all.page 1 }
|
219
|
+
its(:limit_value) { should == 100 }
|
220
|
+
end
|
221
|
+
end
|
196
222
|
end
|
197
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- gemfiles/active_record_32.gemfile
|
200
200
|
- gemfiles/active_record_40.gemfile
|
201
201
|
- gemfiles/active_record_41.gemfile
|
202
|
+
- gemfiles/active_record_42.gemfile
|
202
203
|
- gemfiles/active_record_edge.gemfile
|
203
204
|
- gemfiles/data_mapper_12.gemfile
|
204
205
|
- gemfiles/mongo_mapper.gemfile
|
@@ -289,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
290
|
version: '0'
|
290
291
|
requirements: []
|
291
292
|
rubyforge_project: kaminari
|
292
|
-
rubygems_version: 2.
|
293
|
+
rubygems_version: 2.4.5
|
293
294
|
signing_key:
|
294
295
|
specification_version: 4
|
295
296
|
summary: A pagination engine plugin for Rails 3+ and other modern frameworks
|