Skip to content

Commit

Permalink
Merge pull request sunspot#14 from davekrupinski/master
Browse files Browse the repository at this point in the history
Update testing proxy with generic pagination methods
  • Loading branch information
nz committed Sep 5, 2011
2 parents db69fdb + 86dbff1 commit f3295f8
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions sunspot_rails/lib/sunspot/rails/stub_session_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,23 @@ def search(*types)
def new_search(*types)
Search.new
end

def new_more_like_this(*args)
Search.new
end

class Search

def build
self
end

def results
[]
PaginatedCollection.new
end

def hits(options = {})
[]
PaginatedCollection.new
end

def total
Expand All @@ -83,6 +88,55 @@ def execute
self
end
end


class PaginatedCollection < Array

def total_count
0
end
alias :total_entries :total_count

def current_page
1
end

def per_page
30
end
alias :limit_value :per_page

def total_pages
1
end
alias :num_pages :total_pages

def first_page?
true
end

def last_page?
true
end

def previous_page
nil
end

def next_page
nil
end

def out_of_bounds?
false
end

def offset
0
end

end

end
end
end

0 comments on commit f3295f8

Please sign in to comment.