Permalink
Browse files

Added use of screen_name and user_id in users/show to disambiguate wh…

…en a valid screen name is also an user ID.
  • Loading branch information...
1 parent f3d7698 commit 30e37d3a697b371ce3ca8613672f283b7523b72d @filipegiusti filipegiusti committed Aug 13, 2009
Showing with 7 additions and 6 deletions.
  1. +2 −1 lib/twitter/client/user.rb
  2. +5 −5 spec/twitter/client/user_spec.rb
@@ -33,7 +33,8 @@ class Twitter::Client
def user(id, action = :info, options = {})
raise ArgumentError, "Invalid user action: #{action}" unless @@USER_URIS.keys.member?(action)
id = id.to_i if id.is_a?(Twitter::User)
- params = options.merge(:id => id)
+ id_param = id.is_a?(String) ? :screen_name : :user_id
+ params = options.merge(id_param => id)
response = http_connect {|conn| create_http_get_request(@@USER_URIS[action], params) }
bless_models(Twitter::User.unmarshal(response.body))
end
@@ -21,12 +21,12 @@
end
it "should create expected HTTP GET request when giving numeric user id" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:id => @id}).and_return(@request)
+ @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:user_id => @id}).and_return(@request)
@twitter.user(@id)
end
it "should create expected HTTP GET request when giving screen name" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:id => @screen_name}).and_return(@request)
+ @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:screen_name => @screen_name}).and_return(@request)
@twitter.user(@screen_name)
end
@@ -68,7 +68,7 @@
end
it "should create expected HTTP GET request when giving numeric user id" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:id => @id}).and_return(@request)
+ @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:user_id => @id}).and_return(@request)
@twitter.user(@id, :friends)
end
@@ -78,12 +78,12 @@
end
it "should create expected HTTP GET request when giving Twitter::User object" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:id => @user.to_i}).and_return(@request)
+ @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:user_id => @user.to_i}).and_return(@request)
@twitter.user(@user, :friends)
end
it "should create expected HTTP GET request when giving screen name" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:id => @screen_name}).and_return(@request)
+ @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:screen_name => @screen_name}).and_return(@request)
@twitter.user(@screen_name, :friends)
end

0 comments on commit 30e37d3

Please sign in to comment.