diff --git a/lib/twitter/base.rb b/lib/twitter/base.rb index e484cd744..97410aa66 100644 --- a/lib/twitter/base.rb +++ b/lib/twitter/base.rb @@ -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)) diff --git a/test/twitter/base_test.rb b/test/twitter/base_test.rb index eeed6c342..af704f492 100644 --- a/test/twitter/base_test.rb +++ b/test/twitter/base_test.rb @@ -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')))