0
@template = '<%= will_paginate collection, options %>'
0
@view = ActionView::Base.new
0
- @view.assigns['_params'] = {}
0
@view.assigns['controller'] = @controller
0
@view.assigns['_request'] = @request
0
+ @view.assigns['_params'] = @request.params
0
+ ## basic pagination ##
0
paginate do |pagination|
0
assert_select 'a[href]', 3 do |elements|
0
+ ## advanced options for pagination ##
0
def test_will_paginate_without_container
0
paginate({}, :container => false)
0
assert_select 'div.pagination', 0, 'main DIV present when it shouldn\'t'
0
+ assert_nil div.first['id']
0
+ paginate({}, :id => true) do |div|
0
+ assert_equal 'fixnums_pagination', div.first['id']
0
+ paginate({}, :id => 'custom_id') do |div|
0
+ assert_equal 'custom_id', div.first['id']
0
+ def test_paginated_section
0
+ <% paginated_section collection, options do %>
0
+ <%= content_tag :div, '', :id => "developers" %>
0
+ assert_select 'div.pagination', 2
0
+ assert_select 'div.pagination + div#developers', 1
0
+ def test_page_entries_info
0
+ @template = '<%= page_entries_info collection %>'
0
+ array = ('a'..'z').to_a
0
+ paginate array.paginate(:page => 2, :per_page => 5)
0
+ assert_equal %{Displaying entries <b>6 - 10</b> of <b>26</b> in total},
0
+ paginate array.paginate(:page => 7, :per_page => 4)
0
+ assert_equal %{Displaying entries <b>25 - 26</b> of <b>26</b> in total},
0
+ ## parameter handling in page links ##
0
+ def test_will_paginate_preserves_parameters_on_get
0
+ @request.params :foo => { :bar => 'baz' }
0
+ assert_links_match /foo%5Bbar%5D=baz/
0
+ def test_will_paginate_doesnt_preserve_parameters_on_post
0
+ @request.params :foo => 'bar'
0
+ assert_no_links_match /foo=bar/
0
+ def test_adding_additional_parameters
0
+ paginate({}, :params => { :foo => 'bar' })
0
+ assert_links_match /foo=bar/
0
+ def test_removing_arbitrary_parameters
0
+ @request.params :foo => 'bar'
0
+ paginate({}, :params => { :foo => nil })
0
+ assert_no_links_match /foo=bar/
0
+ def test_adding_additional_route_parameters
0
+ paginate({}, :params => { :controller => 'baz', :action => 'list' })
0
+ assert_links_match %r{\Wbaz/list\W}
0
+ def test_will_paginate_with_custom_page_param
0
+ paginate({ :page => 2 }, :param_name => :developers_page) do
0
+ assert_select 'a[href]', 4 do |elements|
0
+ validate_page_numbers [1,1,3,3], elements, :developers_page
0
+ def test_complex_custom_page_param
0
+ @request.params :developers => { :page => 2 }
0
+ paginate({ :page => 2 }, :param_name => 'developers[page]') do
0
+ assert_select 'a[href]', 4 do |links|
0
+ assert_links_match /\?developers%5Bpage%5D=\d+$/, links
0
+ validate_page_numbers [1,1,3,3], links, 'developers[page]'
0
+ ## internal hardcore stuff ##
0
class LegacyCollection < WillPaginate::Collection
0
alias :page_count :total_pages
0
assert e.message.include?('@developers')
0
- assert_nil div.first['id']
0
- paginate({}, :id => true) do |div|
0
- assert_equal 'fixnums_pagination', div.first['id']
0
- paginate({}, :id => 'custom_id') do |div|
0
- assert_equal 'custom_id', div.first['id']
0
if ActionController::Base.respond_to? :rescue_responses
0
def test_rescue_response_hook_presence
0
assert_equal :not_found,
0
ActionController::Base.rescue_responses['WillPaginate::InvalidPage']
0
- def test_paginated_section
0
- <% paginated_section collection, options do %>
0
- <%= content_tag :div, '', :id => "developers" %>
0
- assert_select 'div.pagination', 2
0
- assert_select 'div.pagination + div#developers', 1
0
- def test_page_entries_info
0
- @template = '<%= page_entries_info collection %>'
0
- array = ('a'..'z').to_a
0
- paginate array.paginate(:page => 2, :per_page => 5)
0
- assert_equal %{Displaying entries <b>6 - 10</b> of <b>26</b> in total},
0
- paginate array.paginate(:page => 7, :per_page => 4)
0
- assert_equal %{Displaying entries <b>25 - 26</b> of <b>26</b> in total},
0
def paginate(collection = {}, options = {}, &block)
0
- def assert_links_match pattern
0
- assert_select 'div.pagination a[href]' do |elements|
0
- assert_match pattern, el['href']
0
+ def assert_links_match pattern, links = nil
0
+ links ||= assert_select 'div.pagination a[href]' do |elements|
0
+ assert_match pattern, el['href']
Comments
No one has commented yet.