Sha256: 90f1f3657c2a7a73d6bf32bcb55f02701944453c5883e0f0a3b7bbaa3533341c

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require File.expand_path("../../test_helper", File.dirname(__FILE__))

class PaginationHelperTest < ActionView::TestCase
  include Paginary::Helpers::PaginationHelper

  delegate :params, :to => :controller
  
  def url_options
    { :controller => "widgets", :action => "index" }
  end
  
  def setup
    @klass = Widget
    @relation = @klass.unscoped
  end

  # Pagination ===============================================================
  test "paginate should yield page builder" do
    builder = nil
    paginate(@relation) { |b| builder = b }
    assert_kind_of Paginary::Helpers::PageBuilder, builder
  end
  
  test "paginate should accept builder class" do
    custom_builder = Class.new(Paginary::Helpers::PageBuilder)
    builder = nil
    paginate(@relation, :builder => custom_builder) { |b| builder = b }
    assert_kind_of custom_builder, builder
  end
  
  test "paginate should query database for total number of items only once" do
    num = count_queries do
      paginate(@relation) { |page| page.links; page.items.to_a }
    end
    assert_equal 2, num
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginary-0.0.1.pre2 test/unit/helpers/pagination_helper_test.rb