From 5897ae945a8de46fc1c48e77f978d42dbb0a9a32 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Tue, 27 Jun 2017 10:57:29 -0400
Subject: [PATCH] FIX: stop using inline quote for local onebox

---
 lib/onebox/engine/discourse_local_onebox.rb |  2 +-
 spec/components/pretty_text_spec.rb         | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/onebox/engine/discourse_local_onebox.rb b/lib/onebox/engine/discourse_local_onebox.rb
index 629cfd6d914..3ee243ffdde 100644
--- a/lib/onebox/engine/discourse_local_onebox.rb
+++ b/lib/onebox/engine/discourse_local_onebox.rb
@@ -56,7 +56,7 @@ module Onebox
             excerpt.gsub!(/[\r\n]+/, " ")
             excerpt.gsub!("[/quote]", "[quote]") # don't break my quote
 
-            quote = "[quote=\"#{post.user.username}, topic:#{topic.id}, slug:#{slug}, post:#{post.post_number}\"]#{excerpt}[/quote]"
+            quote = "[quote=\"#{post.user.username}, topic:#{topic.id}, slug:#{slug}, post:#{post.post_number}\"]\n#{excerpt}\n[/quote]"
 
             args = {}
             args[:topic_id] = source_topic_id if source_topic_id > 0
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index b960cf5024b..9e9b26fa0c7 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -658,6 +658,18 @@ HTML
       expect(cooked.scan('quote]').length).to eq(0)
     end
 
+    it "can onebox local topics" do
+      op = Fabricate(:post)
+      reply = Fabricate(:post, topic_id: op.topic_id)
+
+
+      url = Discourse.base_url + reply.url
+      quote = create_post(topic_id: op.topic.id, raw: "This is a sample reply with a quote\n\n#{url}")
+      quote.reload
+
+      expect(quote.cooked).not_to include('[quote')
+    end
+
     it "do off topic quoting with emoji unescape" do
 
       topic = Fabricate(:topic, title: "this is a test topic :slight_smile:")