Merge pull request #4040 from sammyd/embedding_username

FIX: Enable post username to be specified in embedded comments
This commit is contained in:
Robin Ward 2016-02-25 11:56:10 -05:00
commit 9d38685a70
2 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,7 @@ class EmbedController < ApplicationController
def comments def comments
embed_url = params[:embed_url] embed_url = params[:embed_url]
embed_username = params[:discourse_username]
topic_id = nil topic_id = nil
if embed_url.present? if embed_url.present?
@ -35,7 +36,7 @@ class EmbedController < ApplicationController
end end
elsif embed_url.present? elsif embed_url.present?
Jobs.enqueue(:retrieve_topic, user_id: current_user.try(:id), embed_url: embed_url) Jobs.enqueue(:retrieve_topic, user_id: current_user.try(:id), embed_url: embed_url, author_username: embed_username)
render 'loading' render 'loading'
end end

View File

@ -4,6 +4,7 @@ describe EmbedController do
let(:host) { "eviltrout.com" } let(:host) { "eviltrout.com" }
let(:embed_url) { "http://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" } let(:embed_url) { "http://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
let(:discourse_username) { "eviltrout" }
it "is 404 without an embed_url" do it "is 404 without an embed_url" do
get :comments get :comments
@ -94,6 +95,12 @@ describe EmbedController do
TopicView.expects(:new).with(123, nil, {limit: 100, exclude_first: true, exclude_deleted_users: true}) TopicView.expects(:new).with(123, nil, {limit: 100, exclude_first: true, exclude_deleted_users: true})
get :comments, embed_url: embed_url get :comments, embed_url: embed_url
end end
it "provides the topic retriever with the discourse username when provided" do
TopicRetriever.expects(:new).with(embed_url, has_entry({author_username: discourse_username}))
get :comments, embed_url: embed_url, discourse_username: discourse_username
end
end end
end end