Skip to content

Commit

Permalink
Merge pull request #206 from seanmoon/master
Browse files Browse the repository at this point in the history
Implementation error in Twitter::Status#all_urls
  • Loading branch information
sferik committed Oct 20, 2011
2 parents 5597505 + e8819c0 commit cacb6ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/twitter/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/twitter/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cacb6ca

Please sign in to comment.