Permalink
Browse files

Modify Status#from_user interface

  • Loading branch information...
1 parent 5349166 commit 5c7acd09a2ad277848aa2e5453267e016c3c17e4 @sferik committed May 6, 2012
Showing with 2 additions and 24 deletions.
  1. +1 −6 lib/twitter/status.rb
  2. +1 −18 spec/twitter/status_spec.rb
View
@@ -40,7 +40,7 @@ def expanded_urls
# @return [String]
def from_user
- @attrs['from_user'] || @attrs['screen_name']
+ @attrs['from_user'] || self.user && self.user.screen_name
end
# @return [Twitter::Point, Twitter::Polygon]
@@ -95,11 +95,6 @@ def retweeted_status
@retweeted_status ||= self.class.new(@attrs['retweeted_status']) unless @attrs['retweeted_status'].nil?
end
- # @return [String]
- def screen_name
- @attrs['screen_name'] || @attrs['from_user']
- end
-
# @note Must include entities in your request for this method to work
# @return [Array<Twitter::Entity::Url>]
def urls
@@ -64,7 +64,7 @@
status.from_user.should == "sferik"
end
it "should return a screen name when screen_name is set" do
- status = Twitter::Status.new('screen_name' => 'sferik')
+ status = Twitter::Status.new('user' => {'screen_name' => 'sferik'})
status.from_user.should be_a String
status.from_user.should == "sferik"
end
@@ -183,23 +183,6 @@
end
end
- describe "#screen_name" do
- it "should return a screen name when screen_name is set" do
- status = Twitter::Status.new('screen_name' => 'sferik')
- status.screen_name.should be_a String
- status.screen_name.should == "sferik"
- end
- it "should return a screen name when from_user is set" do
- status = Twitter::Status.new('from_user' => 'sferik')
- status.screen_name.should be_a String
- status.screen_name.should == "sferik"
- end
- it "should return nil when not set" do
- status = Twitter::Status.new
- status.screen_name.should be_nil
- end
- end
-
describe "#urls" do
it "should return an Array of Entity::Url when entities are set" do
urls_hash = [{'url' => 'http://example.com/t.co',

0 comments on commit 5c7acd0

Please sign in to comment.