caching Twitter.screen_name makes Twitter::Client.new.user return old user #136

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@kenmazaika

Before Patch:
irb(main):001:0> at1 = AccessToken.find(3)
=> #
irb(main):002:0> at2 = AccessToken.find(5)
=> #
irb(main):003:0> Twitter::Client.new(:oauth_token => at1.token, :oauth_token_secret => at1.secret).user.screen_name
=> "bostontoastm"
irb(main):004:0> Twitter::Client.new(:oauth_token => at2.token, :oauth_token_secret => at2.secret).user.screen_name
=> "bostontoastm"

After Patch:

irb(main):001:0> at1 = AccessToken.find(3)
=> #
irb(main):002:0> at2 = AccessToken.find(5)
=> #
irb(main):003:0> Twitter::Client.new(:oauth_token => at1.token, :oauth_token_secret => at1.secret).user.screen_name
=> "bostontoastm"
irb(main):004:0> Twitter::Client.new(:oauth_token => at2.token, :oauth_token_secret => at2.secret).user.screen_name
=> "KenMazaika"

@sferik
Owner

Would calling Twitter.reset whenever a new client is initialized solve the problem? This solution feels like throwing out the baby with the bathwater.

@sferik

In the future, please don't include version bumps in your pulls requests.

@kenmazaika

In the general case that would probably work, but I don't think it would work in the case of:

twitter1 = Twitter::Client.new(user1's token)
twitter2 = Twitter::Client.new(user2's token)

twitter1.user.screenname

@sferik
Owner

I just added a failing test case in cf825ea.

@sferik
Owner

Don't set cached screen_name when creating a new API client

Closed by ceeed99.

@kenmazaika

Thanks for fixing this so quickly and merging it into master.

@stve stve pushed a commit that referenced this pull request Aug 21, 2011
@sferik Add failing test case for #136 cf825ea
@stve stve pushed a commit that referenced this pull request Aug 21, 2011
@sferik Don't set cached screen_name when creating a new API client
Closes #136.
ceeed99
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment