Permalink
Browse files

Fixed bug where OAuth credentials didn't update when logging in again.

  • Loading branch information...
Michael Bleigh
Michael Bleigh committed Mar 20, 2009
1 parent eb11a42 commit 1433880bee83364d8138e2253e3d4863750375c7
Showing with 13 additions and 1 deletion.
  1. +4 −1 app/models/twitter_auth/oauth_user.rb
  2. +9 −0 spec/models/twitter_auth/oauth_user_spec.rb
@@ -15,7 +15,10 @@ def identify_or_create_from_access_token(token, secret=nil)
user_info = JSON.parse(token.get('/account/verify_credentials.json').body)
if user = User.find_by_login(user_info['screen_name'])
user.update_twitter_attributes(user_info)
user.assign_twitter_attributes(user_info)
user.access_token = token.token
user.access_secret = token.secret
user.save
user
else
User.create_from_twitter_hash_and_token(user_info, token)
@@ -34,9 +34,18 @@
it 'should return the user if he/she exists' do
user = Factory.create(:twitter_oauth_user, :login => 'twitterman')
user.reload
User.identify_or_create_from_access_token(@token).should == user
end
it 'should update the access_token and access_secret for the user if he/she exists' do
user = Factory.create(:twitter_oauth_user, :login => 'twitterman', :access_token => 'someothertoken', :access_secret => 'someothersecret')
User.identify_or_create_from_access_token(@token)
user.reload
user.access_token.should == @token.token
user.access_secret.should == @token.secret
end
it 'should update the user\'s attributes based on the twitter info' do
user = Factory.create(:twitter_oauth_user, :login => 'twitterman', :name => 'Not Twitter Man')
User.identify_or_create_from_access_token(@token).name.should == 'Twitter Man'

0 comments on commit 1433880

Please sign in to comment.