Skip to content

A platform for community discussion. Free, open, simple.

FIX: An `opts` hash was not, in fact, optional :)

Robin Ward8f5314bf981e
diff --git a/lib/topic_retriever.rb b/lib/topic_retriever.rb
index 3da6f932a27..8fae22a368d 100644
--- a/lib/topic_retriever.rb
+++ b/lib/topic_retriever.rb
@@ -4,8 +4,8 @@ class TopicRetriever
def initialize(embed_url, opts = nil)
@embed_url = embed_url
- @author_username = opts[:author_username]
@opts = opts || {}
+ @author_username = @opts[:author_username]
end
def retrieve
diff --git a/spec/components/topic_retriever_spec.rb b/spec/components/topic_retriever_spec.rb
index 5ab908476b7..6fd602c67ef 100644
--- a/spec/components/topic_retriever_spec.rb
+++ b/spec/components/topic_retriever_spec.rb
@@ -8,6 +8,11 @@ describe TopicRetriever do
let(:author_username) { "eviltrout" }
let(:topic_retriever) { TopicRetriever.new(embed_url, author_username: author_username) }
+ it "can initialize without optional parameters" do
+ t = TopicRetriever.new(embed_url)
+ expect(t).to be_present
+ end
+
describe "#retrieve" do
context "when host is invalid" do
before do