Skip to content

Commit

Permalink
Added 'update_profile_image' account method
Browse files Browse the repository at this point in the history
  • Loading branch information
urajat committed Jan 21, 2010
1 parent b4de55f commit 10afe76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 6 additions & 0 deletions test/twitter/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down

0 comments on commit 10afe76

Please sign in to comment.