will_paginate 3.0.4 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +7 -10
- data/lib/will_paginate/active_record.rb +18 -17
- data/lib/will_paginate/deprecation.rb +3 -3
- data/lib/will_paginate/i18n.rb +3 -3
- data/lib/will_paginate/locale/en.yml +4 -0
- data/lib/will_paginate/mongoid.rb +48 -0
- data/lib/will_paginate/page_number.rb +7 -11
- data/lib/will_paginate/railtie.rb +19 -13
- data/lib/will_paginate/version.rb +2 -2
- data/lib/will_paginate/view_helpers/action_view.rb +12 -5
- data/lib/will_paginate/view_helpers/hanami.rb +41 -0
- data/lib/will_paginate/view_helpers/link_renderer.rb +23 -17
- data/lib/will_paginate/view_helpers/link_renderer_base.rb +1 -1
- data/lib/will_paginate/view_helpers.rb +3 -1
- data/lib/will_paginate.rb +0 -12
- metadata +29 -58
- data/Rakefile +0 -25
- data/lib/will_paginate/data_mapper.rb +0 -95
- data/lib/will_paginate/view_helpers/merb.rb +0 -26
- data/spec/ci.rb +0 -29
- data/spec/collection_spec.rb +0 -139
- data/spec/console +0 -12
- data/spec/console_fixtures.rb +0 -28
- data/spec/database.yml +0 -22
- data/spec/finders/active_record_spec.rb +0 -556
- data/spec/finders/activerecord_test_connector.rb +0 -115
- data/spec/finders/data_mapper_spec.rb +0 -103
- data/spec/finders/data_mapper_test_connector.rb +0 -54
- data/spec/finders/sequel_spec.rb +0 -67
- data/spec/finders/sequel_test_connector.rb +0 -15
- data/spec/fixtures/admin.rb +0 -3
- data/spec/fixtures/developer.rb +0 -13
- data/spec/fixtures/developers_projects.yml +0 -13
- data/spec/fixtures/project.rb +0 -15
- data/spec/fixtures/projects.yml +0 -6
- data/spec/fixtures/replies.yml +0 -29
- data/spec/fixtures/reply.rb +0 -9
- data/spec/fixtures/schema.rb +0 -38
- data/spec/fixtures/topic.rb +0 -7
- data/spec/fixtures/topics.yml +0 -30
- data/spec/fixtures/user.rb +0 -2
- data/spec/fixtures/users.yml +0 -35
- data/spec/page_number_spec.rb +0 -65
- data/spec/per_page_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -71
- data/spec/view_helpers/action_view_spec.rb +0 -423
- data/spec/view_helpers/base_spec.rb +0 -130
- data/spec/view_helpers/link_renderer_base_spec.rb +0 -87
- data/spec/view_helpers/view_example_group.rb +0 -121
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
begin
|
3
|
-
require 'minitest/unit'
|
4
|
-
rescue LoadError
|
5
|
-
# Fails on Ruby 1.8, but it's OK since we only need MiniTest::Assertions
|
6
|
-
# on Rails 4 which doesn't support 1.8 anyway.
|
7
|
-
end
|
8
|
-
require 'action_dispatch/testing/assertions'
|
9
|
-
require 'will_paginate/array'
|
10
|
-
|
11
|
-
module ViewExampleGroup
|
12
|
-
|
13
|
-
include ActionDispatch::Assertions::SelectorAssertions
|
14
|
-
include MiniTest::Assertions if defined? MiniTest
|
15
|
-
|
16
|
-
def assert(value, message)
|
17
|
-
raise message unless value
|
18
|
-
end
|
19
|
-
|
20
|
-
def paginate(collection = {}, options = {}, &block)
|
21
|
-
if collection.instance_of? Hash
|
22
|
-
page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection)
|
23
|
-
collection = [1].paginate(page_options)
|
24
|
-
end
|
25
|
-
|
26
|
-
locals = { :collection => collection, :options => options }
|
27
|
-
|
28
|
-
@render_output = render(locals)
|
29
|
-
@html_document = nil
|
30
|
-
|
31
|
-
if block_given?
|
32
|
-
classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class]
|
33
|
-
assert_select("div.#{classname}", 1, 'no main DIV', &block)
|
34
|
-
end
|
35
|
-
|
36
|
-
@render_output
|
37
|
-
end
|
38
|
-
|
39
|
-
def html_document
|
40
|
-
@html_document ||= HTML::Document.new(@render_output, true, false)
|
41
|
-
end
|
42
|
-
|
43
|
-
def response_from_page_or_rjs
|
44
|
-
html_document.root
|
45
|
-
end
|
46
|
-
|
47
|
-
def validate_page_numbers(expected, links, param_name = :page)
|
48
|
-
param_pattern = /\W#{Regexp.escape(param_name.to_s)}=([^&]*)/
|
49
|
-
|
50
|
-
links.map { |el|
|
51
|
-
unescape_href(el) =~ param_pattern
|
52
|
-
$1 ? $1.to_i : $1
|
53
|
-
}.should == expected
|
54
|
-
end
|
55
|
-
|
56
|
-
def assert_links_match(pattern, links = nil, numbers = nil)
|
57
|
-
links ||= assert_select 'div.pagination a[href]' do |elements|
|
58
|
-
elements
|
59
|
-
end
|
60
|
-
|
61
|
-
pages = [] if numbers
|
62
|
-
|
63
|
-
links.each do |el|
|
64
|
-
href = unescape_href(el)
|
65
|
-
href.should =~ pattern
|
66
|
-
if numbers
|
67
|
-
href =~ pattern
|
68
|
-
pages << ($1.nil?? nil : $1.to_i)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
pages.should == numbers if numbers
|
73
|
-
end
|
74
|
-
|
75
|
-
def assert_no_links_match(pattern)
|
76
|
-
assert_select 'div.pagination a[href]' do |elements|
|
77
|
-
elements.each do |el|
|
78
|
-
unescape_href(el).should_not =~ pattern
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def unescape_href(el)
|
84
|
-
CGI.unescape CGI.unescapeHTML(el['href'])
|
85
|
-
end
|
86
|
-
|
87
|
-
def build_message(message, pattern, *args)
|
88
|
-
built_message = pattern.dup
|
89
|
-
for value in args
|
90
|
-
built_message.sub! '?', value.inspect
|
91
|
-
end
|
92
|
-
built_message
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
RSpec.configure do |config|
|
98
|
-
config.include ViewExampleGroup, :type => :view, :example_group => {
|
99
|
-
:file_path => %r{spec/view_helpers/}
|
100
|
-
}
|
101
|
-
end
|
102
|
-
|
103
|
-
module HTML
|
104
|
-
Node.class_eval do
|
105
|
-
def inner_text
|
106
|
-
children.map(&:inner_text).join('')
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
Text.class_eval do
|
111
|
-
def inner_text
|
112
|
-
self.to_s
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
Tag.class_eval do
|
117
|
-
def inner_text
|
118
|
-
childless?? '' : super
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|