Sha256: ce61dce6921cefcf53045a4eb210a670ec452bc38ac286c637842737b913f71a

Contents?: true

Size: 1.75 KB

Versions: 11

Compression:

Stored size: 1.75 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class TestSearchPagination < Test::Unit::TestCase
  def test_limit
    search = Account.new_search
    search.limit = 10
    assert_equal 10, search.limit
    search.page = 2
    assert_equal 10, search.offset
    search.limit = 25
    assert_equal 25, search.offset
    assert_equal 2, search.page
    search.page = 5
    assert_equal 5, search.page
    assert_equal 25, search.limit
    search.limit = 3
    assert_equal 12, search.offset
  end
  
  def test_page
    search = Account.new_search(:per_page => nil)
    search.page = 2
    assert_equal 1, search.page
    search.per_page = 20
    assert_equal 2, search.page
    search.limit = 0
    assert_equal 1, search.page
    search.per_page = 20
    assert_equal 2, search.page
    search.limit = nil
    assert_equal 1, search.page
  end
  
  def test_per_page
    search = Account.new_search
    search.per_page = 10
    assert_equal 10, search.per_page
    search.per_page = ""
    assert_equal nil, search.per_page
    search.per_page = 40
    assert_equal 40, search.per_page
    search.per_page = nil
    assert_equal nil, search.per_page
    search.per_page = 60
    assert_equal 60, search.per_page
    search.per_page = false
    assert_equal nil, search.per_page
  end
  
  def test_next_page
    
  end
  
  def test_prev_page
    
  end
  
  def test_page_count
    search = Account.new_search
    assert_equal 1, search.page_count
    search.per_page = 1
    assert_equal 3, search.page_count
    search.per_page = 100
    assert_equal 1, search.page_count
    
    Searchgasm::Config.per_page = 1
    search = Account.new_search
    assert_equal 3, search.page_count    
    search.conditions.users.first_name_contains
    assert_equal 3, search.page_count
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
searchgasm-1.3.0 test/test_search_pagination.rb
searchgasm-1.3.2 test/test_search_pagination.rb
searchgasm-1.3.3 test/test_search_pagination.rb
searchgasm-1.3.4 test/test_search_pagination.rb
searchgasm-1.2.1 test/test_search_pagination.rb
searchgasm-1.3.1 test/test_search_pagination.rb
searchgasm-1.2.2 test/test_search_pagination.rb
searchgasm-1.2.0 test/test_search_pagination.rb
searchgasm-1.4.0 test/test_search_pagination.rb
searchgasm-1.4.1 test/test_search_pagination.rb
searchgasm-1.3.5 test/test_search_pagination.rb