mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: don't onebox hidden posts
This commit is contained in:
@@ -25,6 +25,7 @@ module Onebox
|
|||||||
# Post Link
|
# Post Link
|
||||||
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
|
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
|
||||||
return linked unless post
|
return linked unless post
|
||||||
|
return linked if post.hidden
|
||||||
return linked unless Guardian.new.can_see?(post)
|
return linked unless Guardian.new.can_see?(post)
|
||||||
|
|
||||||
topic = post.topic
|
topic = post.topic
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ describe Onebox::Engine::DiscourseLocalOnebox do
|
|||||||
Onebox.preview(url).to_s.should == "<a href='#{url}'>#{url}</a>"
|
Onebox.preview(url).to_s.should == "<a href='#{url}'>#{url}</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns a link if post is hidden" do
|
||||||
|
hidden_post = Fabricate(:post, topic: post.topic, post_number: 2, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached])
|
||||||
|
url = "#{Discourse.base_url}#{hidden_post.url}"
|
||||||
|
Onebox.preview(url).to_s.should == "<a href='#{url}'>#{url}</a>"
|
||||||
|
end
|
||||||
|
|
||||||
it "returns some onebox goodness if post exists and can be seen" do
|
it "returns some onebox goodness if post exists and can be seen" do
|
||||||
url = "#{Discourse.base_url}#{post2.url}"
|
url = "#{Discourse.base_url}#{post2.url}"
|
||||||
Guardian.any_instance.stubs(:can_see?).returns(true)
|
Guardian.any_instance.stubs(:can_see?).returns(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user