will_paginate 3.1.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +6 -9
  3. data/lib/will_paginate/active_record.rb +7 -11
  4. data/lib/will_paginate/deprecation.rb +2 -2
  5. data/lib/will_paginate/i18n.rb +3 -3
  6. data/lib/will_paginate/locale/en.yml +4 -0
  7. data/lib/will_paginate/mongoid.rb +2 -0
  8. data/lib/will_paginate/page_number.rb +7 -11
  9. data/lib/will_paginate/railtie.rb +3 -4
  10. data/lib/will_paginate/version.rb +3 -3
  11. data/lib/will_paginate/view_helpers/action_view.rb +8 -4
  12. data/lib/will_paginate/view_helpers/hanami.rb +41 -0
  13. data/lib/will_paginate/view_helpers/link_renderer.rb +14 -8
  14. data/lib/will_paginate.rb +0 -12
  15. metadata +17 -48
  16. data/lib/will_paginate/data_mapper.rb +0 -100
  17. data/lib/will_paginate/view_helpers/merb.rb +0 -26
  18. data/spec/collection_spec.rb +0 -139
  19. data/spec/console +0 -12
  20. data/spec/console_fixtures.rb +0 -28
  21. data/spec/database.yml +0 -29
  22. data/spec/fake_rubygems.rb +0 -18
  23. data/spec/finders/active_record_spec.rb +0 -417
  24. data/spec/finders/activerecord_test_connector.rb +0 -127
  25. data/spec/finders/data_mapper_spec.rb +0 -114
  26. data/spec/finders/data_mapper_test_connector.rb +0 -54
  27. data/spec/finders/mongoid_spec.rb +0 -145
  28. data/spec/finders/sequel_spec.rb +0 -65
  29. data/spec/finders/sequel_test_connector.rb +0 -15
  30. data/spec/fixtures/admin.rb +0 -3
  31. data/spec/fixtures/developer.rb +0 -9
  32. data/spec/fixtures/developers_projects.yml +0 -13
  33. data/spec/fixtures/project.rb +0 -13
  34. data/spec/fixtures/projects.yml +0 -6
  35. data/spec/fixtures/replies.yml +0 -29
  36. data/spec/fixtures/reply.rb +0 -8
  37. data/spec/fixtures/schema.rb +0 -38
  38. data/spec/fixtures/topic.rb +0 -8
  39. data/spec/fixtures/topics.yml +0 -30
  40. data/spec/fixtures/user.rb +0 -2
  41. data/spec/fixtures/users.yml +0 -35
  42. data/spec/matchers/deprecation_matcher.rb +0 -27
  43. data/spec/matchers/phrase_matcher.rb +0 -19
  44. data/spec/matchers/query_count_matcher.rb +0 -36
  45. data/spec/page_number_spec.rb +0 -83
  46. data/spec/per_page_spec.rb +0 -41
  47. data/spec/spec_helper.rb +0 -46
  48. data/spec/view_helpers/action_view_spec.rb +0 -468
  49. data/spec/view_helpers/base_spec.rb +0 -143
  50. data/spec/view_helpers/link_renderer_base_spec.rb +0 -87
  51. data/spec/view_helpers/view_example_group.rb +0 -146
@@ -1,35 +0,0 @@
1
- david:
2
- id: 1
3
- name: David
4
- salary: 80000
5
- type: Developer
6
-
7
- jamis:
8
- id: 2
9
- name: Jamis
10
- salary: 150000
11
- type: Developer
12
-
13
- <% for digit in 3..10 %>
14
- dev_<%= digit %>:
15
- id: <%= digit %>
16
- name: fixture_<%= digit %>
17
- salary: 100000
18
- type: Developer
19
- <% end %>
20
-
21
- poor_jamis:
22
- id: 11
23
- name: Jamis
24
- salary: 9000
25
- type: Developer
26
-
27
- admin:
28
- id: 12
29
- name: admin
30
- type: Admin
31
-
32
- goofy:
33
- id: 13
34
- name: Goofy
35
- type: Admin
@@ -1,27 +0,0 @@
1
- require 'stringio'
2
-
3
- class DeprecationMatcher
4
- def initialize(message)
5
- @message = message
6
- end
7
-
8
- def matches?(block)
9
- @actual = hijack_stderr(&block)
10
- PhraseMatcher.new("DEPRECATION WARNING: #{@message}").matches?(@actual)
11
- end
12
-
13
- def failure_message
14
- "expected deprecation warning #{@message.inspect}, got #{@actual.inspect}"
15
- end
16
-
17
- private
18
-
19
- def hijack_stderr
20
- err = $stderr
21
- $stderr = StringIO.new
22
- yield
23
- $stderr.string.rstrip
24
- ensure
25
- $stderr = err
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- class PhraseMatcher
2
- def initialize(string)
3
- @string = string
4
- @pattern = /\b#{Regexp.escape string}\b/
5
- end
6
-
7
- def matches?(actual)
8
- @actual = actual.to_s
9
- @actual =~ @pattern
10
- end
11
-
12
- def failure_message
13
- "expected #{@actual.inspect} to contain phrase #{@string.inspect}"
14
- end
15
-
16
- def negative_failure_message
17
- "expected #{@actual.inspect} not to contain phrase #{@string.inspect}"
18
- end
19
- end
@@ -1,36 +0,0 @@
1
- class QueryCountMatcher
2
- def initialize(num)
3
- @expected_count = num
4
- end
5
-
6
- def matches?(block)
7
- run(block)
8
-
9
- if @expected_count.respond_to? :include?
10
- @expected_count.include? @count
11
- else
12
- @count == @expected_count
13
- end
14
- end
15
-
16
- def run(block)
17
- $query_count = 0
18
- $query_sql = []
19
- block.call
20
- ensure
21
- @queries = $query_sql.dup
22
- @count = $query_count
23
- end
24
-
25
- def performed_queries
26
- @queries
27
- end
28
-
29
- def failure_message
30
- "expected #{@expected_count} queries, got #{@count}\n#{@queries.join("\n")}"
31
- end
32
-
33
- def negative_failure_message
34
- "expected query count not to be #{@expected_count}"
35
- end
36
- end
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
- require 'will_paginate/page_number'
3
-
4
- describe WillPaginate::PageNumber do
5
- describe "valid" do
6
- def num
7
- WillPaginate::PageNumber.new('12', 'page')
8
- end
9
-
10
- it "== 12" do
11
- num.should eq(12)
12
- end
13
-
14
- it "inspects to 'page 12'" do
15
- num.inspect.should eq('page 12')
16
- end
17
-
18
- it "is a PageNumber" do
19
- (num.instance_of? WillPaginate::PageNumber).should be
20
- end
21
-
22
- it "is a kind of Numeric" do
23
- (num.is_a? Numeric).should be
24
- end
25
-
26
- it "is a kind of Integer" do
27
- (num.is_a? Integer).should be
28
- end
29
-
30
- it "isn't directly a Integer" do
31
- (num.instance_of? Integer).should_not be
32
- end
33
-
34
- it "passes the PageNumber=== type check" do |variable|
35
- (WillPaginate::PageNumber === num).should be
36
- end
37
-
38
- it "passes the Numeric=== type check" do |variable|
39
- (Numeric === num).should be
40
- (Integer === num).should be
41
- end
42
- end
43
-
44
- describe "invalid" do
45
- def create(value, name = 'page')
46
- described_class.new(value, name)
47
- end
48
-
49
- it "errors out on non-int values" do
50
- lambda { create(nil) }.should raise_error(WillPaginate::InvalidPage)
51
- lambda { create('') }.should raise_error(WillPaginate::InvalidPage)
52
- lambda { create('Schnitzel') }.should raise_error(WillPaginate::InvalidPage)
53
- end
54
-
55
- it "errors out on zero or less" do
56
- lambda { create(0) }.should raise_error(WillPaginate::InvalidPage)
57
- lambda { create(-1) }.should raise_error(WillPaginate::InvalidPage)
58
- end
59
-
60
- it "doesn't error out on zero for 'offset'" do
61
- lambda { create(0, 'offset') }.should_not raise_error
62
- lambda { create(-1, 'offset') }.should raise_error(WillPaginate::InvalidPage)
63
- end
64
- end
65
-
66
- describe "coercion method" do
67
- it "defaults to 'page' name" do
68
- num = WillPaginate::PageNumber(12)
69
- num.inspect.should eq('page 12')
70
- end
71
-
72
- it "accepts a custom name" do
73
- num = WillPaginate::PageNumber(12, 'monkeys')
74
- num.inspect.should eq('monkeys 12')
75
- end
76
-
77
- it "doesn't affect PageNumber instances" do
78
- num = WillPaginate::PageNumber(12)
79
- num2 = WillPaginate::PageNumber(num)
80
- num2.object_id.should eq(num.object_id)
81
- end
82
- end
83
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
- require 'will_paginate/per_page'
3
-
4
- describe WillPaginate::PerPage do
5
-
6
- class MyModel
7
- extend WillPaginate::PerPage
8
- end
9
-
10
- it "has the default value" do
11
- MyModel.per_page.should == 30
12
-
13
- WillPaginate.per_page = 10
14
- begin
15
- MyModel.per_page.should == 10
16
- ensure
17
- WillPaginate.per_page = 30
18
- end
19
- end
20
-
21
- it "casts values to int" do
22
- WillPaginate.per_page = '10'
23
- begin
24
- MyModel.per_page.should == 10
25
- ensure
26
- WillPaginate.per_page = 30
27
- end
28
- end
29
-
30
- it "has an explicit value" do
31
- MyModel.per_page = 12
32
- begin
33
- MyModel.per_page.should == 12
34
- subclass = Class.new(MyModel)
35
- subclass.per_page.should == 12
36
- ensure
37
- MyModel.send(:remove_instance_variable, '@per_page')
38
- end
39
- end
40
-
41
- end
data/spec/spec_helper.rb DELETED
@@ -1,46 +0,0 @@
1
- require 'rspec'
2
- require 'view_helpers/view_example_group'
3
- begin
4
- require 'ruby-debug'
5
- rescue LoadError
6
- # no debugger available
7
- end
8
-
9
- Dir[File.expand_path('../matchers/*_matcher.rb', __FILE__)].each { |matcher| require matcher }
10
-
11
- RSpec.configure do |config|
12
- config.include Module.new {
13
- protected
14
-
15
- def include_phrase(string)
16
- PhraseMatcher.new(string)
17
- end
18
-
19
- def have_deprecation(msg)
20
- DeprecationMatcher.new(msg)
21
- end
22
-
23
- def run_queries(num)
24
- QueryCountMatcher.new(num)
25
- end
26
-
27
- def ignore_deprecation
28
- ActiveSupport::Deprecation.silence { yield }
29
- end
30
-
31
- def show_queries(&block)
32
- counter = QueryCountMatcher.new(nil)
33
- counter.run block
34
- ensure
35
- queries = counter.performed_queries
36
- if queries.any?
37
- puts queries
38
- else
39
- puts "no queries"
40
- end
41
- end
42
- }
43
-
44
- config.mock_with :mocha
45
- config.backtrace_clean_patterns << /view_example_group/
46
- end