diff --git a/lib/kaminari/models/array_extension.rb b/lib/kaminari/models/array_extension.rb index 31c57b6..728bf08 100644 --- a/lib/kaminari/models/array_extension.rb +++ b/lib/kaminari/models/array_extension.rb @@ -11,7 +11,12 @@ module Kaminari # * :total_count - total_count 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] - super(original_array[@_offset_value, @_limit_value] || []) + + if options[:total_count] + super original_array + else + super(original_array[@_offset_value, @_limit_value] || []) + end end # items at the specified "page" diff --git a/spec/models/array_spec.rb b/spec/models/array_spec.rb index b272829..7704b45 100644 --- a/spec/models/array_spec.rb +++ b/spec/models/array_spec.rb @@ -106,9 +106,9 @@ describe Kaminari::PaginatableArray do end context 'when setting total count explicitly' do - subject { Kaminari::PaginatableArray.new((1..100).to_a, :total_count => 9999).page(5).per(10) } + subject { Kaminari::PaginatableArray.new((1..10).to_a, :total_count => 9999).page(5).per(10) } it { should have(10).items } - its(:first) { should == 41 } + its(:first) { should == 1 } its(:total_count) { should == 9999 } end end