mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Pass discourse username to TopicRetriever from embed controller
When you specify `discourse_username` param on the embed URL, it should translate to creating the post with that username. This commit ensures that this is now the case.
This commit is contained in:
parent
a01b2a48d5
commit
b2f4659792
2 changed files with 9 additions and 1 deletions
|
@ -8,6 +8,7 @@ class EmbedController < ApplicationController
|
|||
|
||||
def comments
|
||||
embed_url = params[:embed_url]
|
||||
embed_username = params[:discourse_username]
|
||||
|
||||
topic_id = nil
|
||||
if embed_url.present?
|
||||
|
@ -35,7 +36,7 @@ class EmbedController < ApplicationController
|
|||
end
|
||||
|
||||
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'
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe EmbedController do
|
|||
|
||||
let(:host) { "eviltrout.com" }
|
||||
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
|
||||
get :comments
|
||||
|
@ -94,6 +95,12 @@ describe EmbedController do
|
|||
TopicView.expects(:new).with(123, nil, {limit: 100, exclude_first: true, exclude_deleted_users: true})
|
||||
get :comments, embed_url: embed_url
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue