mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: don't onebox hidden posts
This commit is contained in:
parent
340fd303c8
commit
9fba385172
2 changed files with 7 additions and 0 deletions
|
@ -25,6 +25,7 @@ module Onebox
|
|||
# Post Link
|
||||
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
|
||||
return linked unless post
|
||||
return linked if post.hidden
|
||||
return linked unless Guardian.new.can_see?(post)
|
||||
|
||||
topic = post.topic
|
||||
|
|
|
@ -28,6 +28,12 @@ describe Onebox::Engine::DiscourseLocalOnebox do
|
|||
Onebox.preview(url).to_s.should == "<a href='#{url}'>#{url}</a>"
|
||||
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
|
||||
url = "#{Discourse.base_url}#{post2.url}"
|
||||
Guardian.any_instance.stubs(:can_see?).returns(true)
|
||||
|
|
Loading…
Reference in a new issue