0
-require 'action_controller'
0
-require 'lib/html_inner_text'
0
-ActionController::Routing::Routes.draw do |map|
0
- map.connect ':controller/:action/:id'
0
-ActionController::Base.perform_caching = false
0
-require 'will_paginate'
0
-WillPaginate.enable_actionpack
0
+require 'lib/view_test_process'
0
class PaginationTest < Test::Unit::TestCase
0
@@ -25,24 +15,6 @@ class PaginationTest < Test::Unit::TestCase
0
render :inline => '<%= will_paginate @developers, @options %>'
0
- def guess_collection_name
0
- @developers = session[:wp]
0
- @options = session[:wp_options]
0
- render :inline => '<%= will_paginate @options %>'
0
- @developers = session[:wp]
0
- @options = session[:wp_options]
0
- render :inline => <<-ERB
0
- <% paginated_section @options do %>
0
- <%= content_tag :div, '', :id => "developers" %>
0
def rescue_errors(e) raise e end
0
def rescue_action(e) raise e end
0
@@ -54,66 +26,6 @@ class PaginationTest < Test::Unit::TestCase
0
@response = ActionController::TestResponse.new
0
- def test_will_paginate
0
- entries = assigns :developers
0
- assert_equal 4, entries.size
0
- assert_select 'div.pagination', 1, 'no main DIV' do |pagination|
0
- assert_select 'a[href]', 3 do |elements|
0
- validate_page_numbers [2,3,2], elements
0
- assert_select elements.last, ':last-child', "Next »"
0
- assert_select 'span', 2
0
- assert_select 'span.disabled:first-child', "« Previous"
0
- assert_select 'span.current', entries.current_page.to_s
0
- assert_equal '« Previous 1 2 3 Next »', pagination.first.inner_text
0
- def test_will_paginate_with_options
0
- get :list_developers, { :page => 2 }, :wp => {
0
- :class => 'will_paginate', :prev_label => 'Prev', :next_label => 'Next'
0
- assert_response :success
0
- entries = assigns :developers
0
- assert_equal 4, entries.size
0
- assert_select 'div.will_paginate', 1, 'no main DIV' do
0
- assert_select 'a[href]', 4 do |elements|
0
- validate_page_numbers [1,1,3,3], elements
0
- # test rel attribute values:
0
- assert_select elements[1], 'a', '1' do |link|
0
- assert_equal 'prev start', link.first['rel']
0
- assert_select elements.first, 'a', "Prev" do |link|
0
- assert_equal 'prev start', link.first['rel']
0
- assert_select elements.last, 'a', "Next" do |link|
0
- assert_equal 'next', link.first['rel']
0
- assert_select 'span.current', entries.current_page.to_s
0
- def test_will_paginate_without_container
0
- get :list_developers, {}, :wp => { :container => false }
0
- assert_select 'div.pagination', 0, 'no main DIV'
0
- assert_select 'a[href]', 3
0
- def test_will_paginate_without_page_links
0
- get :list_developers, { :page => 2 }, :wp => { :page_links => false }
0
- assert_select 'a[href]', 2 do |elements|
0
- validate_page_numbers [1,3], elements
0
def test_will_paginate_preserves_parameters_on_get
0
get :list_developers, :foo => { :bar => 'baz' }
0
@@ -169,110 +81,6 @@ class PaginationTest < Test::Unit::TestCase
0
assert_select 'span.current', entries.current_page.to_s
0
- def test_will_paginate_windows
0
- get :list_developers, { :page => 6, :per_page => 1 }, :wp => { :inner_window => 1 }
0
- assert_response :success
0
- entries = assigns :developers
0
- assert_equal 1, entries.size
0
- assert_select 'div.pagination', 1, 'no main DIV' do |pagination|
0
- assert_select 'a[href]', 8 do |elements|
0
- validate_page_numbers [5,1,2,5,7,10,11,7], elements
0
- assert_select elements.first, 'a', "« Previous"
0
- assert_select elements.last, 'a', "Next »"
0
- assert_select 'span.current', entries.current_page.to_s
0
- assert_equal '« Previous 1 2 … 5 6 7 … 10 11 Next »', pagination.first.inner_text
0
- def test_will_paginate_eliminates_small_gaps
0
- get :list_developers, { :page => 6, :per_page => 1 }, :wp => { :inner_window => 2 }
0
- assert_response :success
0
- assert_select 'div.pagination', 1, 'no main DIV' do
0
- assert_select 'a[href]', 12 do |elements|
0
- validate_page_numbers [5,1,2,3,4,5,7,8,9,10,11,7], elements
0
- def test_no_pagination
0
- get :list_developers, :per_page => 12
0
- entries = assigns :developers
0
- assert_equal 1, entries.total_pages
0
- assert_equal 11, entries.size
0
- assert_equal '', @response.body
0
- def test_faulty_input_raises_error
0
- assert_raise WillPaginate::InvalidPage do
0
- get :list_developers, :page => 'foo'
0
- class LegacyCollection < WillPaginate::Collection
0
- alias :page_count :total_pages
0
- uses_mocha 'helper internals' do
0
- def test_collection_name_can_be_guessed
0
- collection.expects(:total_pages).returns(1)
0
- get :guess_collection_name, {}, :wp => collection
0
- def test_deprecation_notices_with_page_count
0
- collection = LegacyCollection.new 1, 1, 2
0
- assert_deprecated collection.class.name do
0
- get :guess_collection_name, {}, :wp => collection
0
- def test_inferred_collection_name_raises_error_when_nil
0
- ex = assert_raise ArgumentError do
0
- get :guess_collection_name, {}, :wp => nil
0
- assert ex.message.include?('@developers')
0
- def test_setting_id_for_container
0
- assert_select 'div.pagination', 1 do |div|
0
- assert_nil div.first['id']
0
- get :list_developers, {}, :wp => { :id => true }
0
- assert_select 'div.pagination', 1 do |div|
0
- assert_equal 'fixnums_pagination', div.first['id']
0
- get :list_developers, {}, :wp => { :id => 'custom_id' }
0
- assert_select 'div.pagination', 1 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
- DevelopersController.rescue_responses['WillPaginate::InvalidPage']
0
- def test_paginated_section
0
- collection = WillPaginate::Collection.new 1, 1, 2
0
- get :paginated_section, {}, :wp => collection, :wp_options => { :class => 'will_paginate' }
0
- assert_select 'div.will_paginate', 2
0
- assert_select 'div.will_paginate + div#developers', 1
0
@@ -300,31 +108,4 @@ protected
0
- def collect_deprecations
0
- old_behavior = WillPaginate::Deprecation.behavior
0
- WillPaginate::Deprecation.behavior = Proc.new do |message, callstack|
0
- deprecations << message
0
- [result, deprecations]
0
- WillPaginate::Deprecation.behavior = old_behavior
0
-class ViewHelpersTest < Test::Unit::TestCase
0
- include WillPaginate::ViewHelpers
0
- def test_page_entries_info
0
- collection = arr.paginate :page => 2, :per_page => 5
0
- assert_equal %{Displaying entries <b>6 - 10</b> of <b>26</b> in total},
0
- page_entries_info(collection)
0
- collection = arr.paginate :page => 7, :per_page => 4
0
- assert_equal %{Displaying entries <b>25 - 26</b> of <b>26</b> in total},
0
- page_entries_info(collection)
Comments
No one has commented yet.