discourse/discourse — pull request #860 by chrishunt (2013-05-18 18:03:04+00:00)
Title: Show posts for last page when page out of range

Fixes #843

When we request a page number that exceeds the number of posts in a topic, we blow up in [`app/views/topics/show.html.erb`](https://github.com/discourse/discourse/blob/master/app/views/topics/show.html.erb#L6) because there are no posts in the range.

This PR adjusts the behavior of `TopicView#filter_posts_in_range` so that the min/max range is always within the range of the topic. If the requested page is outside the range, then we see posts for the last page.