Skip to content

Commit

Permalink
test cases for link renderer options
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein authored and mislav committed Apr 29, 2008
1 parent 85e6d44 commit 5586e8e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/view_test.rb
@@ -1,6 +1,22 @@
require 'helper'
require 'lib/view_test_process'

class AdditionalLinkAttributesRenderer < WillPaginate::LinkRenderer
def initialize(*arguments)
if arguments.size == 3
super(*arguments)
@additional_link_attributes = {:default => 'true'}
else
@additional_link_attributes = arguments.extract_options!
end
end

def page_link(page, text, attributes = {})
@template.link_to text, url_for(page), attributes.merge(@additional_link_attributes)
end
end


class ViewTest < WillPaginate::ViewTestCase

## basic pagination ##
Expand Down Expand Up @@ -43,6 +59,18 @@ def test_will_paginate_with_options
end
end

def test_will_paginate_using_renderer_class
paginate({},:renderer => AdditionalLinkAttributesRenderer) do
assert_select 'a[default~=true]'
end
end

def test_will_paginate_using_renderer_instance
paginate({},:renderer => AdditionalLinkAttributesRenderer.new(:title => 'rendered')) do
assert_select 'a[title=rendered]'
end
end

def test_prev_next_links_have_classnames
paginate do |pagination|
assert_select 'span.disabled.prev_page:first-child'
Expand Down

0 comments on commit 5586e8e

Please sign in to comment.