PaginatableArray can be instantiated without an argument

This commit is contained in:
Akira Matsuda 2011-09-21 14:42:50 +09:00
parent fe01a41046
commit f41de10abb
2 changed files with 3 additions and 1 deletions

View File

@ -9,7 +9,7 @@ module Kaminari
# * <tt>:limit</tt> - limit
# * <tt>:offset</tt> - offset
# * <tt>:total_count</tt> - total_count
def initialize(original_array, options = {})
def initialize(original_array = [], options = {})
@_original_array, @_limit_value, @_offset_value, @_total_count = original_array, (options[:limit] || default_per_page).to_i, options[:offset].to_i, options[:total_count]
if options[:limit] && options[:offset]

View File

@ -1,6 +1,8 @@
require File.expand_path('../spec_helper', File.dirname(__FILE__))
describe Kaminari::PaginatableArray do
it { should have(0).items }
context 'specifying limit and offset when initializing' do
subject { Kaminari::PaginatableArray.new((1..100).to_a, :limit => 10, :offset => 20) }
its(:current_page) { should == 3 }