mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Keep around the page when redirecting
This commit is contained in:
parent
3859273ff7
commit
7d23826cee
2 changed files with 8 additions and 0 deletions
|
@ -439,6 +439,9 @@ class TopicsController < ApplicationController
|
||||||
url << "/#{post_number}" if post_number.to_i > 0
|
url << "/#{post_number}" if post_number.to_i > 0
|
||||||
url << ".json" if request.format.json?
|
url << ".json" if request.format.json?
|
||||||
|
|
||||||
|
page = params[:page].to_i
|
||||||
|
url << "?page=#{page}" if page != 0
|
||||||
|
|
||||||
redirect_to url, status: 301
|
redirect_to url, status: 301
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -532,6 +532,11 @@ describe TopicsController do
|
||||||
expect(response).to redirect_to(topic.relative_url + "/42")
|
expect(response).to redirect_to(topic.relative_url + "/42")
|
||||||
end
|
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
|
it 'returns 404 when an invalid slug is given and no id' do
|
||||||
xhr :get, :show, id: 'nope-nope'
|
xhr :get, :show, id: 'nope-nope'
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
|
|
Loading…
Reference in a new issue