mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: unlisted topics do not get "slug auto correct" logic
This commit is contained in:
parent
a4e705648b
commit
3015030fe2
2 changed files with 25 additions and 2 deletions
|
@ -65,7 +65,7 @@ class TopicsController < ApplicationController
|
||||||
rescue Discourse::NotFound
|
rescue Discourse::NotFound
|
||||||
if params[:id]
|
if params[:id]
|
||||||
topic = Topic.find_by(slug: params[:id].downcase)
|
topic = Topic.find_by(slug: params[:id].downcase)
|
||||||
return redirect_to_correct_topic(topic, opts[:post_number]) if topic
|
return redirect_to_correct_topic(topic, opts[:post_number]) if topic && topic.visible
|
||||||
end
|
end
|
||||||
raise Discourse::NotFound
|
raise Discourse::NotFound
|
||||||
end
|
end
|
||||||
|
@ -77,7 +77,14 @@ class TopicsController < ApplicationController
|
||||||
|
|
||||||
discourse_expires_in 1.minute
|
discourse_expires_in 1.minute
|
||||||
|
|
||||||
redirect_to_correct_topic(@topic_view.topic, opts[:post_number]) && return if slugs_do_not_match || (!request.format.json? && params[:slug].nil?)
|
if !@topic_view.topic.visible && @topic_view.topic.slug != params[:slug]
|
||||||
|
raise Discourse::NotFound
|
||||||
|
end
|
||||||
|
|
||||||
|
if slugs_do_not_match || (!request.format.json? && params[:slug].nil?)
|
||||||
|
redirect_to_correct_topic(@topic_view.topic, opts[:post_number])
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
track_visit_to_topic
|
track_visit_to_topic
|
||||||
|
|
||||||
|
|
|
@ -532,6 +532,22 @@ describe TopicsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'show unlisted' do
|
||||||
|
it 'returns 404 unless exact correct URL' do
|
||||||
|
topic = Fabricate(:topic, visible: false)
|
||||||
|
Fabricate(:post, topic: topic)
|
||||||
|
|
||||||
|
xhr :get, :show, topic_id: topic.id, slug: topic.slug
|
||||||
|
expect(response).to be_success
|
||||||
|
|
||||||
|
xhr :get, :show, topic_id: topic.id, slug: "just-guessing"
|
||||||
|
expect(response.code).to eq("404")
|
||||||
|
|
||||||
|
xhr :get, :show, id: topic.slug
|
||||||
|
expect(response.code).to eq("404")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'show' do
|
describe 'show' do
|
||||||
|
|
||||||
let(:topic) { Fabricate(:post).topic }
|
let(:topic) { Fabricate(:post).topic }
|
||||||
|
|
Loading…
Reference in a new issue