Class: PaginationHelperTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
ActionController::Pagination, ActionView::Helpers::PaginationHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
Defined in:
vendor/plugins/classic_pagination/test/pagination_helper_test.rb

Constant Summary

Constants included from ActionController::Pagination

DEFAULT_OPTIONS, OPTIONS

Constants included from ActionView::Helpers::PaginationHelper

DEFAULT_OPTIONS

Instance Method Summary

Methods included from ActionController::Pagination

included, #paginate, validate_options!

Methods included from ActionView::Helpers::PaginationHelper

#pagination_links, #pagination_links_each

Instance Method Details

- (Object) setup



10
11
12
13
14
15
16
17
18
19
# File 'vendor/plugins/classic_pagination/test/pagination_helper_test.rb', line 10

def setup
  @controller = Class.new do
    attr_accessor :url, :request
    def url_for(options, *parameters_for_method_reference)
      url
    end
  end
  @controller = @controller.new
  @controller.url = "http://www.example.com"
end


21
22
23
24
25
# File 'vendor/plugins/classic_pagination/test/pagination_helper_test.rb', line 21

def test_pagination_links
  total, per_page, page = 30, 10, 1
  output = pagination_links Paginator.new(@controller, total, per_page, page)
  assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
end


27
28
29
30
31
# File 'vendor/plugins/classic_pagination/test/pagination_helper_test.rb', line 27

def test_pagination_links_with_prefix
  total, per_page, page = 30, 10, 1
  output = pagination_links Paginator.new(@controller, total, per_page, page), :prefix => 'Newer '
  assert_equal "Newer 1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
end


33
34
35
36
37
# File 'vendor/plugins/classic_pagination/test/pagination_helper_test.rb', line 33

def test_pagination_links_with_suffix
  total, per_page, page = 30, 10, 1
  output = pagination_links Paginator.new(@controller, total, per_page, page), :suffix => 'Older'
  assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> Older", output
end