PaginatableArray can be instantiated without an argument
This commit is contained in:
parent
fe01a41046
commit
f41de10abb
|
@ -9,7 +9,7 @@ module Kaminari
|
||||||
# * <tt>:limit</tt> - limit
|
# * <tt>:limit</tt> - limit
|
||||||
# * <tt>:offset</tt> - offset
|
# * <tt>:offset</tt> - offset
|
||||||
# * <tt>:total_count</tt> - total_count
|
# * <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]
|
@_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]
|
if options[:limit] && options[:offset]
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||||
|
|
||||||
describe Kaminari::PaginatableArray do
|
describe Kaminari::PaginatableArray do
|
||||||
|
it { should have(0).items }
|
||||||
|
|
||||||
context 'specifying limit and offset when initializing' do
|
context 'specifying limit and offset when initializing' do
|
||||||
subject { Kaminari::PaginatableArray.new((1..100).to_a, :limit => 10, :offset => 20) }
|
subject { Kaminari::PaginatableArray.new((1..100).to_a, :limit => 10, :offset => 20) }
|
||||||
its(:current_page) { should == 3 }
|
its(:current_page) { should == 3 }
|
||||||
|
|
Loading…
Reference in New Issue