Skip to content

Commit

Permalink
FIX: Keep around the page when redirecting
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed May 20, 2015
1 parent 3859273 commit 7d23826
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/topics_controller.rb
Expand Up @@ -439,6 +439,9 @@ def redirect_to_correct_topic(topic, post_number=nil)
url << "/#{post_number}" if post_number.to_i > 0
url << ".json" if request.format.json?

page = params[:page].to_i
url << "?page=#{page}" if page != 0

redirect_to url, status: 301
end

Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/topics_controller_spec.rb
Expand Up @@ -532,6 +532,11 @@
expect(response).to redirect_to(topic.relative_url + "/42")
end

it 'keeps the page around when redirecting' do
xhr :get, :show, id: topic.slug, post_number: 42, page: 123
expect(response).to redirect_to(topic.relative_url + "/42?page=123")
end

it 'returns 404 when an invalid slug is given and no id' do
xhr :get, :show, id: 'nope-nope'
expect(response.status).to eq(404)
Expand Down

0 comments on commit 7d23826

Please sign in to comment.