will_paginate 3.1.6 → 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 (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,146 +0,0 @@
1
- require 'active_support'
2
- require 'stringio'
3
- begin
4
- $stderr = StringIO.new
5
- require 'minitest/unit'
6
- rescue LoadError
7
- # Fails on Ruby 1.8, but it's OK since we only need MiniTest::Assertions
8
- # on Rails 4 which doesn't support 1.8 anyway.
9
- ensure
10
- $stderr = STDERR
11
- end
12
-
13
- begin
14
- require 'rails/dom/testing/assertions'
15
- rescue LoadError
16
- require 'action_dispatch/testing/assertions'
17
- end
18
- require 'will_paginate/array'
19
-
20
- module ViewExampleGroup
21
-
22
- if defined?(Rails::Dom::Testing::Assertions)
23
- include Rails::Dom::Testing::Assertions::SelectorAssertions
24
- else
25
- include ActionDispatch::Assertions::SelectorAssertions
26
- end
27
- include MiniTest::Assertions if defined? MiniTest
28
-
29
- def assert(value, message)
30
- raise message unless value
31
- end
32
-
33
- def paginate(collection = {}, options = {}, &block)
34
- if collection.instance_of? Hash
35
- page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection)
36
- collection = [1].paginate(page_options)
37
- end
38
-
39
- locals = { :collection => collection, :options => options }
40
-
41
- @render_output = render(locals)
42
- @html_document = nil
43
-
44
- if block_given?
45
- classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class]
46
- assert_select("div.#{classname}", 1, 'no main DIV', &block)
47
- end
48
-
49
- @render_output
50
- end
51
-
52
- def parse_html_document(html)
53
- @html_document ||= if defined?(Rails::Dom::Testing::Assertions)
54
- Nokogiri::HTML::Document.parse(html)
55
- else
56
- HTML::Document.new(html, true, false)
57
- end
58
- end
59
-
60
- def html_document
61
- @html_document ||= parse_html_document(@render_output)
62
- end
63
-
64
- def document_root_element
65
- html_document.root
66
- end
67
-
68
- def response_from_page_or_rjs
69
- html_document.root
70
- end
71
-
72
- def validate_page_numbers(expected, links, param_name = :page)
73
- param_pattern = /\W#{Regexp.escape(param_name.to_s)}=([^&]*)/
74
-
75
- links.map { |el|
76
- unescape_href(el) =~ param_pattern
77
- $1 ? $1.to_i : $1
78
- }.should == expected
79
- end
80
-
81
- def assert_links_match(pattern, links = nil, numbers = nil)
82
- links ||= assert_select 'div.pagination a[href]' do |elements|
83
- elements
84
- end
85
-
86
- pages = [] if numbers
87
-
88
- links.each do |el|
89
- href = unescape_href(el)
90
- href.should =~ pattern
91
- if numbers
92
- href =~ pattern
93
- pages << ($1.nil?? nil : $1.to_i)
94
- end
95
- end
96
-
97
- pages.should == numbers if numbers
98
- end
99
-
100
- def assert_no_links_match(pattern)
101
- assert_select 'div.pagination a[href]' do |elements|
102
- elements.each do |el|
103
- unescape_href(el).should_not =~ pattern
104
- end
105
- end
106
- end
107
-
108
- def unescape_href(el)
109
- CGI.unescape CGI.unescapeHTML(el['href'])
110
- end
111
-
112
- def build_message(message, pattern, *args)
113
- built_message = pattern.dup
114
- for value in args
115
- built_message.sub! '?', value.inspect
116
- end
117
- built_message
118
- end
119
-
120
- end
121
-
122
- RSpec.configure do |config|
123
- config.include ViewExampleGroup, :type => :view, :example_group => {
124
- :file_path => %r{spec/view_helpers/}
125
- }
126
- end
127
-
128
- module HTML
129
- Node.class_eval do
130
- def inner_text
131
- children.map(&:inner_text).join('')
132
- end
133
- end
134
-
135
- Text.class_eval do
136
- def inner_text
137
- self.to_s
138
- end
139
- end
140
-
141
- Tag.class_eval do
142
- def inner_text
143
- childless?? '' : super
144
- end
145
- end
146
- end if defined?(HTML)