Sha256: f65d4f93d5640cb4c57162afe5370f9a80bdcd97e37312cebd9209227929928f

Contents?: true

Size: 793 Bytes

Versions: 13

Compression:

Stored size: 793 Bytes

Contents

require File.dirname(__FILE__) + '/helper'
require File.dirname(__FILE__) + '/../init'

class ArrayPaginationTest < ActiveRecordTestCase
  def setup
    @array = ('a'..'e').to_a
  end
  
  cases = [
    { :current => 1,  :per_page => 3,  :expected => %w( a b c ) },
    { :current => 2,  :per_page => 3,  :expected => %w( d e ) },
    { :current => 1,  :per_page => 5,  :expected => %w( a b c d e ) },
    { :current => 3,  :per_page => 5,  :expected => [] },
    { :current => -1, :per_page => 5,  :expected => [] },
    { :current => 1,  :per_page => -5, :expected => [] }
  ]
  
  cases.each_with_index do |conditions, index|
    define_method("test_case_#{index}") do
      assert_equal conditions[:expected], @array.paginate(conditions[:current], conditions[:per_page])
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
cehoffman-acts_as_ferret-0.4.4 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
jkraemer-acts_as_ferret-0.4.4 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
watson-acts_as_ferret-0.4.8.2 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.5.2 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.8.2 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.8.1 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.5.1 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.5 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.8.rails3 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.8 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.7 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.6 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb
acts_as_ferret-0.4.4 doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb