kaminari 0.12.3 → 0.12.4
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.
- data/CHANGELOG +9 -0
- data/lib/kaminari/config.rb +4 -0
- data/lib/kaminari/helpers/paginator.rb +5 -1
- data/lib/kaminari/models/active_record_extension.rb +2 -2
- data/lib/kaminari/version.rb +1 -1
- data/spec/config/config_spec.rb +12 -0
- data/spec/helpers/action_view_extension_spec.rb +0 -1
- data/spec/models/active_record_relation_methods_spec.rb +1 -1
- data/spec/models/mongo_mapper_spec.rb +6 -7
- data/spec/models/scopes_spec.rb +5 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.12.4
|
2
|
+
|
3
|
+
* Support for config.param_name as lambda #102 [ajrkerr]
|
4
|
+
|
5
|
+
* Stop duplicating order_values #65 [zettabyte]
|
6
|
+
|
7
|
+
* Preserve select value (e.g. "distinct") when counting #77, #104 [tbeauvais,
|
8
|
+
beatlevic]
|
9
|
+
|
1
10
|
== 0.12.3
|
2
11
|
|
3
12
|
* Haml 3.1 Support #96 [FlyboyArt, sonic921]
|
data/lib/kaminari/config.rb
CHANGED
@@ -23,6 +23,10 @@ module Kaminari
|
|
23
23
|
config_accessor :left
|
24
24
|
config_accessor :right
|
25
25
|
config_accessor :param_name
|
26
|
+
|
27
|
+
def param_name
|
28
|
+
config.param_name.respond_to?(:call) ? config.param_name.call() : config.param_name
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
# this is ugly. why can't we pass the default value to config_accessor...?
|
@@ -1,9 +1,13 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'tags')
|
2
|
+
require 'action_view/context'
|
2
3
|
|
3
4
|
module Kaminari
|
4
5
|
module Helpers
|
5
6
|
# The main container tag
|
6
7
|
class Paginator < Tag
|
8
|
+
# so that this instance can actually "render"
|
9
|
+
include ::ActionView::Context
|
10
|
+
|
7
11
|
def initialize(template, options) #:nodoc:
|
8
12
|
@window_options = {}.tap do |h|
|
9
13
|
h[:window] = options.delete(:window) || options.delete(:inner_window) || Kaminari.config.window
|
@@ -16,7 +20,7 @@ module Kaminari
|
|
16
20
|
@template, @options = template, options
|
17
21
|
@theme = @options[:theme] ? "#{@options[:theme]}/" : ''
|
18
22
|
@options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil
|
19
|
-
#
|
23
|
+
# initialize the output_buffer for Context
|
20
24
|
@output_buffer = ActionView::OutputBuffer.new
|
21
25
|
end
|
22
26
|
|
@@ -5,6 +5,8 @@ module Kaminari
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
included do
|
7
7
|
def self.inherited(kls) #:nodoc:
|
8
|
+
super
|
9
|
+
|
8
10
|
kls.class_eval do
|
9
11
|
include Kaminari::ConfigurationMethods
|
10
12
|
|
@@ -17,8 +19,6 @@ module Kaminari
|
|
17
19
|
include Kaminari::PageScopeMethods
|
18
20
|
end
|
19
21
|
end
|
20
|
-
|
21
|
-
super
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/kaminari/version.rb
CHANGED
data/spec/config/config_spec.rb
CHANGED
@@ -45,5 +45,17 @@ describe Kaminari::Configuration do
|
|
45
45
|
context 'by default' do
|
46
46
|
its(:param_name) { should == :page }
|
47
47
|
end
|
48
|
+
|
49
|
+
context 'configured via config block' do
|
50
|
+
before do
|
51
|
+
Kaminari.configure {|c| c.param_name = lambda { :test } }
|
52
|
+
end
|
53
|
+
|
54
|
+
its(:param_name) { should == :test }
|
55
|
+
|
56
|
+
after do
|
57
|
+
Kaminari.configure {|c| c.param_name = :page }
|
58
|
+
end
|
59
|
+
end
|
48
60
|
end
|
49
61
|
end
|
@@ -33,7 +33,7 @@ describe Kaminari::MongoMapperExtension do
|
|
33
33
|
its(:num_pages) { should == 12 }
|
34
34
|
it { should skip 25 }
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
context 'page "foobar"' do
|
38
38
|
subject { Developer.page 'foobar' }
|
39
39
|
it { should be_a Plucky::Query }
|
@@ -42,31 +42,30 @@ describe Kaminari::MongoMapperExtension do
|
|
42
42
|
its(:num_pages) { should == 12 }
|
43
43
|
it { should skip 0 }
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
context 'with criteria before' do
|
47
47
|
it "should have the proper criteria source" do
|
48
48
|
Developer.where(:salary => 1).page(2).criteria.source.should == {:salary => 1}
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
subject { Developer.where(:salary => 1).page 2 }
|
52
52
|
its(:current_page) { should == 2 }
|
53
53
|
its(:limit_value) { should == 25 }
|
54
54
|
its(:num_pages) { should == 12 }
|
55
55
|
it { should skip 25 }
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
context 'with criteria after' do
|
59
59
|
it "should have the proper criteria source" do
|
60
60
|
Developer.where(:salary => 1).page(2).criteria.source.should == {:salary => 1}
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
subject { Developer.page(2).where(:salary => 1) }
|
64
64
|
its(:current_page) { should == 2 }
|
65
65
|
its(:limit_value) { should == 25 }
|
66
66
|
its(:num_pages) { should == 12 }
|
67
67
|
it { should skip 25 }
|
68
68
|
end
|
69
|
-
|
70
69
|
end
|
71
70
|
|
72
71
|
describe '#per' do
|
@@ -77,4 +76,4 @@ describe Kaminari::MongoMapperExtension do
|
|
77
76
|
its(:num_pages) { should == 30 }
|
78
77
|
it { should skip 10 }
|
79
78
|
end
|
80
|
-
end
|
79
|
+
end
|
data/spec/models/scopes_spec.rb
CHANGED
@@ -40,6 +40,11 @@ describe Kaminari::ActiveRecordExtension do
|
|
40
40
|
subject { User.page 5 }
|
41
41
|
it_should_behave_like 'blank page'
|
42
42
|
end
|
43
|
+
|
44
|
+
describe 'ensure #order_values is preserved' do
|
45
|
+
subject { User.order('id').page 1 }
|
46
|
+
its(:order_values) { should == ['id'] }
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
describe '#per' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 12
|
9
|
-
-
|
10
|
-
version: 0.12.
|
9
|
+
- 4
|
10
|
+
version: 0.12.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akira Matsuda
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04
|
18
|
+
date: 2011-05-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|