diff --git a/branch.sql b/branch.sql new file mode 100644 index 0000000000..9bcf155abc --- /dev/null +++ b/branch.sql @@ -0,0 +1,20 @@ +DELETE FROM participants WHERE username = ANY( ARRAY[ + '4c46cc22afdd', + '82b0d81fe9e8', + '6b6527ac6c02', + 'cbde8c31c11c', + 'bcfc65158eaf', + '31d54a0c19ae', + 'afbddadaac3c', + 'a78c4e42bb93', + '42eb93b3ab89', + 'b1bc5e47fe8e', + '3ac515cc8da6', + '14a79340c40d', + '14d60c6884e7', + '0c783dee50ed', + 'e2020536ef6d', + '60a5099d49c7', + '64f4f959b322', + '0bdf90d51786', + '880ac6873f7f']); diff --git a/gittip/models/__init__.py b/gittip/models/__init__.py index 31a241284c..e2714abc28 100644 --- a/gittip/models/__init__.py +++ b/gittip/models/__init__.py @@ -108,29 +108,7 @@ def _check_orphans(self): where not exists (select * from elsewhere where elsewhere.participant=username) and not exists (select * from absorptions where archived_as=username) """) - known = set(( - "4c46cc22afdd", - "82b0d81fe9e8", - "6b6527ac6c02", - "cbde8c31c11c", - "bcfc65158eaf", - "31d54a0c19ae", - "afbddadaac3c", - "a78c4e42bb93", - "42eb93b3ab89", - "b1bc5e47fe8e", - "3ac515cc8da6", - "14a79340c40d", - "14d60c6884e7", - "0c783dee50ed", - "e2020536ef6d", - "60a5099d49c7", - "64f4f959b322", - "0bdf90d51786", - "880ac6873f7f" - )) - real = set(orphans) - known - assert len(real) == 0, "missing elsewheres: {}".format(list(real)) + assert len(orphans) == 0, "missing elsewheres: {}".format(list(orphans)) def _check_orphans_no_tips(self): """ diff --git a/gittip/models/_mixin_elsewhere.py b/gittip/models/_mixin_elsewhere.py index a2d66109d3..51c19d6aa5 100644 --- a/gittip/models/_mixin_elsewhere.py +++ b/gittip/models/_mixin_elsewhere.py @@ -269,6 +269,10 @@ def take_over(self, account_elsewhere, have_confirmation=False): other_username = rec.participant + if self.username == other_username: + # this is a no op - trying to take over itself + return + # Make sure we have user confirmation if needed. # ============================================== diff --git a/tests/test_participant.py b/tests/test_participant.py index 040395125f..b2d3fe3ea4 100644 --- a/tests/test_participant.py +++ b/tests/test_participant.py @@ -167,6 +167,14 @@ def test_do_not_take_over_zero_tips_receiving(self): assert 2 == ntips self.db.self_check() + def test_idempotent(self): + alice = TwitterAccount(self.db, 1, dict(screen_name='alice')) + bob = GitHubAccount(self.db, 2, dict(screen_name='bob')) + alice_participant = alice.opt_in('alice')[0].participant + alice_participant.take_over(bob, have_confirmation=True) + alice_participant.take_over(bob, have_confirmation=True) + self.db.self_check() + class TestParticipant(Harness): def setUp(self):