Sha256: 5345c304af4acf7f8e9ba00f214ae239caf29a02171042b5988c19ff26efb80d

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

require 'abstract_unit'

class WillPaginateSearchTest < ActiveSupport::TestCase
  fixtures :posts

  def teardown
    # need to do this to work with the :if Proc tests.
    Post.acts_as_indexed :fields => [:title, :body]
    destroy_index
  end

  def test_paginate_search

    assert_equal [5,2,1,3,6,4], paginate_search(1, 10)
    assert_equal [5,2,1], paginate_search(1, 3)
    assert_equal [3,6,4], paginate_search(2, 3)
  end

  private

  # Returns relevant IDs.
  def paginate_search(page, per_page)
    Post.paginate_search('^c', :page => page, :per_page => per_page).map { |p| p.id }
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_indexed-0.8.0 test/will_paginate_search_test.rb