Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (45 sloc) 1.507 kB
require 'test_helper'
module Tire
class PersistentModelIntegrationTest < Test::Unit::TestCase
include Test::Integration
def setup
super
PersistentArticle.index.delete
end
def teardown
super
PersistentArticle.index.delete
end
context "PersistentModel" do
should "save documents into index and find them by IDs" do
one = PersistentArticle.create :id => 1, :title => 'One'
two = PersistentArticle.create :id => 2, :title => 'Two'
PersistentArticle.index.refresh
results = PersistentArticle.find [1, 2]
assert_equal 2, results.size
end
context "with pagination" do
setup do
1.upto(9) { |number| PersistentArticle.create :title => "Test#{number}" }
PersistentArticle.index.refresh
end
should "find first page with five results" do
results = PersistentArticle.search( :per_page => 5, :page => 1 ) { query { all } }
assert_equal 5, results.size
# WillPaginate
#
assert_equal 2, results.total_pages
assert_equal 1, results.current_page
assert_equal nil, results.previous_page
assert_equal 2, results.next_page
# Kaminari
#
assert_equal 5, results.limit_value
assert_equal 9, results.total_count
assert_equal 2, results.num_pages
assert_equal 0, results.offset_value
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.