Permalink
Browse files

[TEST] Added test for paginated search in persistent model

  • Loading branch information...
karmi committed Aug 16, 2011
1 parent f7998a8 commit fd0ee47dde77fa5661c62b3f1c7a0245ee5e10eb
Showing with 21 additions and 0 deletions.
  1. +21 −0 test/integration/persistent_model_test.rb
@@ -28,6 +28,27 @@ def teardown
assert_equal 2, results.size
end
+
+ context "with pagination" do
+
+ setup do
+ 1.upto(9) { |number| PersistentArticle.create :title => "Test#{number}" }
+ PersistentArticle.elasticsearch_index.refresh
+ end
+
+ should "find first page with five results" do
+ results = PersistentArticle.search( :per_page => 5, :page => 1 ) { query { all } }
+ assert_equal 9, results.size
+
+ assert_equal 2, results.total_pages
+ assert_equal 1, results.current_page
+ assert_equal nil, results.previous_page
+ assert_equal 2, results.next_page
+
+ assert_equal 'Test1', results.first.title
+ end
+ end
+
end
end

0 comments on commit fd0ee47

Please sign in to comment.