diff --git a/lib/onebox/engine/discourse_local_onebox.rb b/lib/onebox/engine/discourse_local_onebox.rb
index e8a6d1c07..311891e0e 100644
--- a/lib/onebox/engine/discourse_local_onebox.rb
+++ b/lib/onebox/engine/discourse_local_onebox.rb
@@ -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
diff --git a/spec/components/onebox/engine/discourse_local_onebox_spec.rb b/spec/components/onebox/engine/discourse_local_onebox_spec.rb
index 7c96ccc73..30bd1e845 100644
--- a/spec/components/onebox/engine/discourse_local_onebox_spec.rb
+++ b/spec/components/onebox/engine/discourse_local_onebox_spec.rb
@@ -28,6 +28,12 @@ describe Onebox::Engine::DiscourseLocalOnebox do
Onebox.preview(url).to_s.should == "#{url}"
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 == "#{url}"
+ 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)