FIX: Allow redirection for slugs that start with digits

This commit is contained in:
Robin Ward
2016-09-19 13:31:19 -04:00
parent 332cc2bb95
commit 2766b2edc3
2 changed files with 16 additions and 0 deletions

View File

@ -569,6 +569,15 @@ describe TopicsController do
expect(response).to redirect_to(topic.relative_url)
end
it 'can find a topic when a slug has a number in front' do
another_topic = Fabricate(:post).topic
topic.update_column(:slug, "#{another_topic.id}-reasons-discourse-is-awesome")
xhr :get, :show, id: "#{another_topic.id}-reasons-discourse-is-awesome"
expect(response).to redirect_to(topic.relative_url)
end
it 'keeps the post_number parameter around when redirecting' do
xhr :get, :show, id: topic.slug, post_number: 42
expect(response).to redirect_to(topic.relative_url + "/42")