Permalink
Browse files

Added 'update_profile_image' account method

  • Loading branch information...
urajat committed Jan 21, 2010
1 parent b4de55f commit 10afe76daef3a2b8e10917b9550724cc9c3a6c19
Showing with 11 additions and 0 deletions.
  1. +5 −0 lib/twitter/base.rb
  2. +6 −0 test/twitter/base_test.rb
View
@@ -157,6 +157,11 @@ def update_profile_colors(colors={})
perform_post('/account/update_profile_colors.json', :body => colors)
end
+ # file should respond to #read and #path
+ def update_profile_image(file)
+ perform_post('/account/update_profile_image.json', build_multipart_bodies(:image => file))
+ end
+
# file should respond to #read and #path
def update_profile_background(file, tile = false)
perform_post('/account/update_profile_background_image.json', build_multipart_bodies(:image => file).merge(:tile => tile))
@@ -177,6 +177,12 @@ class BaseTest < Test::Unit::TestCase
blocked.last.screen_name.should == "euciavkvyplx"
end
+ should "upload a profile image" do
+ stub_post('/account/update_profile_image.json', 'update_profile_image.json')
+ user = @twitter.update_profile_image(File.new(sample_image('sample-image.png')))
+ user.name.should == 'John Nunemaker' # update_profile_image responds with the user
+ end
+
should "upload a background image" do
stub_post('/account/update_profile_background_image.json', 'update_profile_background_image.json')
user = @twitter.update_profile_background(File.new(sample_image('sample-image.png')))

0 comments on commit 10afe76

Please sign in to comment.