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

Commit

Permalink
Merge pull request #1685 from gittip/new-team-payday-bug
Browse files Browse the repository at this point in the history
New team payday bug
  • Loading branch information
bruceadams committed Nov 22, 2013
2 parents 055d25d + 2104831 commit d9501ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gittip/billing/payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ def move_pending_to_balance_for_teams(self):
UPDATE participants
SET balance = (balance + pending)
, pending = 0
WHERE number='plural'
WHERE pending IS NOT NULL
AND number='plural'
""")
# "Moved" instead of "cleared" because we don't also set to null.
Expand Down
13 changes: 13 additions & 0 deletions tests/test_billing_payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,19 @@ def setUp(self):
super(TestBillingPayday, self).setUp()
self.payday = Payday(self.db)

def test_move_pending_to_balance_for_teams_does_so(self):
self.make_participant('A', number='plural', balance=2, pending=3)
self.payday.move_pending_to_balance_for_teams()
actual = self.db.one("SELECT balance FROM participants WHERE username='A'")
assert actual == 5

def test_move_pending_to_balance_for_teams_ignores_new_teams(self):
# See https://github.com/gittip/www.gittip.com/issues/1684
self.make_participant('A', number='plural', balance=0, pending=None)
self.payday.move_pending_to_balance_for_teams()
actual = self.db.one("SELECT balance FROM participants WHERE username='A'")
assert actual == 0

@mock.patch('gittip.models.participant.Participant.get_tips_and_total')
def test_charge_and_or_transfer_no_tips(self, get_tips_and_total):
self.db.run("""
Expand Down

0 comments on commit d9501ef

Please sign in to comment.