Permalink
Browse files

Refactored #intermediate_links

  • Loading branch information...
1 parent c818277 commit d9aacefc71d7c3a09a13b2479f3a89a8992b43d8 @tj committed Oct 8, 2009
Showing with 5 additions and 5 deletions.
  1. +2 −2 lib/dm-pagination/pager.rb
  2. +3 −3 spec/unit/pager_spec.rb
@@ -97,8 +97,8 @@ def more position
def intermediate_links
(first..last).map do |page|
- classes = current_page == page ? ['active'] : []
- classes << "page-#{page}"
+ classes = ["page-#{page}"]
+ classes << 'active' if current_page == page
li classes.join(' '), link_to(page)
end
end
View
@@ -15,9 +15,9 @@
end
it "should add the 'active' class to the current page link <li>" do
- Item.page.pager.to_html('/').should include('li class="active page-1"><a href="/?page=1"')
- Item.page(2).pager.to_html('/').should include('li class="active page-2"><a href="/?page=2"')
- Item.page(3).pager.to_html('/').should include('li class="active page-3"><a href="/?page=3"')
+ Item.page.pager.to_html('/').should include('li class="page-1 active"><a href="/?page=1"')
+ Item.page(2).pager.to_html('/').should include('li class="page-2 active"><a href="/?page=2"')
+ Item.page(3).pager.to_html('/').should include('li class="page-3 active"><a href="/?page=3"')
end
it "should add li.last.jump" do

0 comments on commit d9aacef

Please sign in to comment.