Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
set is_closed=False in opt_in() instead of in set_as_claimed()
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Jun 10, 2014
1 parent 2989eb3 commit bb00262
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions gittip/models/account_elsewhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def opt_in(self, desired_username):
user.participant.change_username(desired_username)
except ProblemChangingUsername:
pass
if user.participant.is_closed:
user.participant.update_is_closed(False)
return user, newly_claimed

def save_token(self, token, refresh_token=None, expires=None):
Expand Down
3 changes: 1 addition & 2 deletions gittip/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,12 @@ def set_as_claimed(self):
UPDATE participants
SET claimed_time=CURRENT_TIMESTAMP
, is_closed=false
WHERE username=%s
AND claimed_time IS NULL
RETURNING claimed_time
""", (self.username,))
self.set_attributes(claimed_time=claimed_time, is_closed=False)
self.set_attributes(claimed_time=claimed_time)


# Canceling
Expand Down
8 changes: 8 additions & 0 deletions tests/py/test_elsewhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from gittip.elsewhere import UserInfo
from gittip.models.account_elsewhere import AccountElsewhere
from gittip.models.participant import Participant
from gittip.testing import Harness
import gittip.testing.elsewhere as user_info_examples

Expand Down Expand Up @@ -33,6 +34,13 @@ def test_opt_in_doesnt_have_to_change_username(self):
actual = account.opt_in('bob')[0].participant.username
assert actual == expected

def test_opt_in_resets_is_closed_to_false(self):
alice = self.make_elsewhere('twitter', 1, 'alice')
alice.participant.update_is_closed(True)
user = alice.opt_in('alice')[0]
assert not user.participant.is_closed
assert not Participant.from_username('alice').is_closed

def test_redirect_csrf(self):
response = self.client.GxT('/on/github/redirect')
assert response.code == 405
Expand Down
6 changes: 0 additions & 6 deletions tests/py/test_participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,6 @@ def test_claiming_participant(self):
expected = datetime.timedelta(seconds=0.1)
assert actual < expected

def test_claiming_participant_resets_is_closed_to_false(self):
self.participant.update_is_closed(True)
self.participant.set_as_claimed()
assert not self.participant.is_closed
assert not Participant.from_username('user1').is_closed

def test_changing_username_successfully(self):
self.participant.change_username('user2')
actual = Participant.from_username('user2')
Expand Down

0 comments on commit bb00262

Please sign in to comment.