예제 #1
0
    def test_messages_remain_after_team_membership(self):
        # Here's the scenario:
        # User is invited to a team
        # - User accepts invitation
        # - Message for the invitation gets deleted -> wrong!
        user = UserFactory(notify_by_message=True)
        owner = UserFactory(notify_by_message=True)
        team = Team.objects.create(name='test-team', slug='test-team', membership_policy=Team.APPLICATION)

        invite_form = InviteForm(team, owner, {
            'username': user.username,
            'message': 'Subtitle ALL the things!',
            'role':'contributor',
        })
        invite_form.is_valid()
        self.assertFalse(invite_form.errors)
        self.assertEquals(Message.objects.for_user(user).count(), 0)
        invite = invite_form.save()
        # user has the invitation message on their inbox now
        self.assertEquals(Message.objects.for_user(user).count(), 1)
        invite_message = Message.objects.for_user(user)[0]
        # now user accepts invite
        invite.accept()
        # he should be a team memebr
        self.assertTrue(team.members.filter(user=user).exists())
        # message should be still on their inbos
        self.assertIn(invite_message, Message.objects.for_user(user))
예제 #2
0
 def test_team_inviation_sent(self):
     team, created = Team.objects.get_or_create(name='test', slug='test')
     owner, created = TeamMember.objects.get_or_create(
         team=team, user=User.objects.all()[2], role='owner')
     applying_user = User.objects.all()[0]
     applying_user.notify_by_email = True
     applying_user.save()
     mail.outbox = []
     message = "Will you be my valentine?"
     f = InviteForm(user=owner.user,
                    team=team,
                    data={
                        "user_id": applying_user.id,
                        "role": "admin",
                        "message": message,
                    })
     f.is_valid()
     f.save()
     self.assertEqual(len(mail.outbox), 1)
     msg = mail.outbox[0]
     self.assertIn(applying_user.email, msg.to[0])
     self.assertIn(
         message,
         msg.body,
     )
예제 #3
0
 def test_team_inviation_sent(self):
     team = TeamFactory(name='test', slug='test')
     owner = TeamMemberFactory(team=team, role=TeamMember.ROLE_OWNER)
     applying_user = UserFactory()
     applying_user.notify_by_email = True
     applying_user.save()
     mail.outbox = []
     message = "Will you be my valentine?"
     f = InviteForm(user=owner.user, team=team,data={
         'username': applying_user.username,
         "role":"admin",
         "message": message,
     })
     f.is_valid()
     f.save()
     self.assertEqual(len(mail.outbox), 1)
     msg = mail.outbox[0]
     self.assertIn(applying_user.email, msg.to[0] )
     self.assertIn(message, msg.body, )