Backporting the change that I made to the api06 branch to bring the classic_paginatio...
[rails.git] / vendor / plugins / classic_pagination / test / pagination_helper_test.rb
1 require File.dirname(__FILE__) + '/helper'
2 require File.dirname(__FILE__) + '/../init'
3
4 class PaginationHelperTest < Test::Unit::TestCase
5   include ActionController::Pagination
6   include ActionView::Helpers::PaginationHelper
7   include ActionView::Helpers::UrlHelper
8   include ActionView::Helpers::TagHelper
9
10   def setup
11     @controller = Class.new do
12       attr_accessor :url, :request
13       def url_for(options, *parameters_for_method_reference)
14         url
15       end
16     end
17     @controller = @controller.new
18     @controller.url = "http://www.example.com"
19   end
20
21   def test_pagination_links
22     total, per_page, page = 30, 10, 1
23     output = pagination_links Paginator.new(@controller, total, per_page, page)
24     assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
25   end
26
27   def test_pagination_links_with_prefix
28     total, per_page, page = 30, 10, 1
29     output = pagination_links Paginator.new(@controller, total, per_page, page), :prefix => 'Newer '
30     assert_equal "Newer 1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
31   end
32
33   def test_pagination_links_with_suffix
34     total, per_page, page = 30, 10, 1
35     output = pagination_links Paginator.new(@controller, total, per_page, page), :suffix => 'Older'
36     assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> Older", output
37   end
38 end