Permalink
Browse files

Merge pull request #206 from seanmoon/master

Implementation error in Twitter::Status#all_urls
  • Loading branch information...
2 parents 5597505 + e8819c0 commit cacb6ca2bc4ea6b16414fb143cb1c1fa29f6dd37 @sferik committed Oct 20, 2011
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/twitter/status.rb
  2. +7 −0 spec/twitter/status_spec.rb
View
@@ -24,7 +24,7 @@ def ==(other)
def all_urls
@all_urls ||= begin
- all_urls = [ urls, expanded_urls ].compact.flatten.uniq
+ all_urls = [ urls, expanded_urls ].flatten.compact.uniq
all_urls.length > 0 ? all_urls : nil
end
end
@@ -33,6 +33,13 @@
all_urls = Twitter::Status.new.all_urls
all_urls.should be_nil
end
+ it "should not include nil" do
+ urls = [{'url' => 'http://t.co/example', 'expanded_url' => nil}]
+ status_attributes = { 'text' => "This tweet contains a http://t.co/example.", 'entities' => {'urls' => urls} }
+ all_urls = Twitter::Status.new(status_attributes).all_urls
+ all_urls.should be_an Array
+ all_urls.should == ["http://t.co/example"]
+ end
end
describe "#expanded_urls" do

0 comments on commit cacb6ca

Please sign in to comment.