annotate vendor/plugins/classic_pagination/test/pagination_helper_test.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
rev   line source
Chris@0 1 require File.dirname(__FILE__) + '/helper'
Chris@0 2 require File.dirname(__FILE__) + '/../init'
Chris@0 3
Chris@0 4 class PaginationHelperTest < Test::Unit::TestCase
Chris@0 5 include ActionController::Pagination
Chris@0 6 include ActionView::Helpers::PaginationHelper
Chris@0 7 include ActionView::Helpers::UrlHelper
Chris@0 8 include ActionView::Helpers::TagHelper
Chris@0 9
Chris@0 10 def setup
Chris@0 11 @controller = Class.new do
Chris@0 12 attr_accessor :url, :request
Chris@0 13 def url_for(options, *parameters_for_method_reference)
Chris@0 14 url
Chris@0 15 end
Chris@0 16 end
Chris@0 17 @controller = @controller.new
Chris@0 18 @controller.url = "http://www.example.com"
Chris@0 19 end
Chris@0 20
Chris@0 21 def test_pagination_links
Chris@0 22 total, per_page, page = 30, 10, 1
Chris@0 23 output = pagination_links Paginator.new(@controller, total, per_page, page)
Chris@0 24 assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
Chris@0 25 end
Chris@0 26
Chris@0 27 def test_pagination_links_with_prefix
Chris@0 28 total, per_page, page = 30, 10, 1
Chris@0 29 output = pagination_links Paginator.new(@controller, total, per_page, page), :prefix => 'Newer '
Chris@0 30 assert_equal "Newer 1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
Chris@0 31 end
Chris@0 32
Chris@0 33 def test_pagination_links_with_suffix
Chris@0 34 total, per_page, page = 30, 10, 1
Chris@0 35 output = pagination_links Paginator.new(@controller, total, per_page, page), :suffix => 'Older'
Chris@0 36 assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> Older", output
Chris@0 37 end
Chris@0 38 end