will_paginate 3.3.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/will_paginate/locale/en.yml +2 -0
  4. data/lib/will_paginate/version.rb +3 -3
  5. data/lib/will_paginate/view_helpers/action_view.rb +6 -2
  6. data/lib/will_paginate/view_helpers/link_renderer.rb +7 -5
  7. data/lib/will_paginate.rb +0 -12
  8. metadata +8 -38
  9. data/lib/will_paginate/data_mapper.rb +0 -100
  10. data/lib/will_paginate/view_helpers/merb.rb +0 -26
  11. data/spec/collection_spec.rb +0 -139
  12. data/spec/console +0 -12
  13. data/spec/console_fixtures.rb +0 -28
  14. data/spec/database.yml +0 -29
  15. data/spec/finders/active_record_spec.rb +0 -424
  16. data/spec/finders/activerecord_test_connector.rb +0 -107
  17. data/spec/fixtures/admin.rb +0 -3
  18. data/spec/fixtures/developer.rb +0 -9
  19. data/spec/fixtures/developers_projects.yml +0 -13
  20. data/spec/fixtures/project.rb +0 -13
  21. data/spec/fixtures/projects.yml +0 -6
  22. data/spec/fixtures/replies.yml +0 -29
  23. data/spec/fixtures/reply.rb +0 -8
  24. data/spec/fixtures/schema.rb +0 -38
  25. data/spec/fixtures/topic.rb +0 -8
  26. data/spec/fixtures/topics.yml +0 -30
  27. data/spec/fixtures/user.rb +0 -2
  28. data/spec/fixtures/users.yml +0 -35
  29. data/spec/matchers/deprecation_matcher.rb +0 -27
  30. data/spec/matchers/phrase_matcher.rb +0 -19
  31. data/spec/matchers/query_count_matcher.rb +0 -36
  32. data/spec/page_number_spec.rb +0 -91
  33. data/spec/per_page_spec.rb +0 -41
  34. data/spec/spec_helper.rb +0 -41
  35. data/spec/view_helpers/action_view_spec.rb +0 -481
  36. data/spec/view_helpers/base_spec.rb +0 -143
  37. data/spec/view_helpers/link_renderer_base_spec.rb +0 -87
  38. data/spec/view_helpers/view_example_group.rb +0 -105
@@ -1,2 +0,0 @@
1
- class User < ActiveRecord::Base
2
- end
@@ -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,91 +0,0 @@
1
- require 'spec_helper'
2
- require 'will_paginate/page_number'
3
- require 'json'
4
-
5
- describe WillPaginate::PageNumber do
6
- describe "valid" do
7
- def num
8
- WillPaginate::PageNumber.new('12', 'page')
9
- end
10
-
11
- it "== 12" do
12
- num.should eq(12)
13
- end
14
-
15
- it "inspects to 'page 12'" do
16
- num.inspect.should eq('page 12')
17
- end
18
-
19
- it "is a PageNumber" do
20
- (num.instance_of? WillPaginate::PageNumber).should be
21
- end
22
-
23
- it "is a kind of Numeric" do
24
- (num.is_a? Numeric).should be
25
- end
26
-
27
- it "is a kind of Integer" do
28
- (num.is_a? Integer).should be
29
- end
30
-
31
- it "isn't directly a Integer" do
32
- (num.instance_of? Integer).should_not be
33
- end
34
-
35
- it "passes the PageNumber=== type check" do |variable|
36
- (WillPaginate::PageNumber === num).should be
37
- end
38
-
39
- it "passes the Numeric=== type check" do |variable|
40
- (Numeric === num).should be
41
- end
42
-
43
- it "fails the Numeric=== type check" do |variable|
44
- (Integer === num).should_not be
45
- end
46
-
47
- it "serializes as JSON number" do
48
- JSON.dump(page: num).should eq('{"page":12}')
49
- end
50
- end
51
-
52
- describe "invalid" do
53
- def create(value, name = 'page')
54
- described_class.new(value, name)
55
- end
56
-
57
- it "errors out on non-int values" do
58
- lambda { create(nil) }.should raise_error(WillPaginate::InvalidPage)
59
- lambda { create('') }.should raise_error(WillPaginate::InvalidPage)
60
- lambda { create('Schnitzel') }.should raise_error(WillPaginate::InvalidPage)
61
- end
62
-
63
- it "errors out on zero or less" do
64
- lambda { create(0) }.should raise_error(WillPaginate::InvalidPage)
65
- lambda { create(-1) }.should raise_error(WillPaginate::InvalidPage)
66
- end
67
-
68
- it "doesn't error out on zero for 'offset'" do
69
- lambda { create(0, 'offset') }.should_not raise_error
70
- lambda { create(-1, 'offset') }.should raise_error(WillPaginate::InvalidPage)
71
- end
72
- end
73
-
74
- describe "coercion method" do
75
- it "defaults to 'page' name" do
76
- num = WillPaginate::PageNumber(12)
77
- num.inspect.should eq('page 12')
78
- end
79
-
80
- it "accepts a custom name" do
81
- num = WillPaginate::PageNumber(12, 'monkeys')
82
- num.inspect.should eq('monkeys 12')
83
- end
84
-
85
- it "doesn't affect PageNumber instances" do
86
- num = WillPaginate::PageNumber(12)
87
- num2 = WillPaginate::PageNumber(num)
88
- num2.object_id.should eq(num.object_id)
89
- end
90
- end
91
- 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,41 +0,0 @@
1
- require 'rspec'
2
- require 'view_helpers/view_example_group'
3
-
4
- Dir[File.expand_path('../matchers/*_matcher.rb', __FILE__)].each { |matcher| require matcher }
5
-
6
- RSpec.configure do |config|
7
- config.include Module.new {
8
- protected
9
-
10
- def include_phrase(string)
11
- PhraseMatcher.new(string)
12
- end
13
-
14
- def have_deprecation(msg)
15
- DeprecationMatcher.new(msg)
16
- end
17
-
18
- def run_queries(num)
19
- QueryCountMatcher.new(num)
20
- end
21
-
22
- def ignore_deprecation
23
- ActiveSupport::Deprecation.silence { yield }
24
- end
25
-
26
- def show_queries(&block)
27
- counter = QueryCountMatcher.new(nil)
28
- counter.run block
29
- ensure
30
- queries = counter.performed_queries
31
- if queries.any?
32
- puts queries
33
- else
34
- puts "no queries"
35
- end
36
- end
37
- }
38
-
39
- config.mock_with :mocha
40
- config.backtrace_exclusion_patterns << /view_example_group/
41
- end