'Tests that the same user is not returned more than once
if there are commits associated with multiple of their
emails'

def test_deduplicate_users(self):

    user = User.objects.create(email='stebe@sentry.io')
    email = UserEmail.objects.get(user=user, email='stebe@sentry.io')
    otheremail = UserEmail.objects.create(email='alsostebe@sentry.io', user=user)
    project = self.create_project()
    self.create_member(user=user, organization=project.organization)
    release = Release.objects.create(organization_id=project.organization_id, version=uuid4().hex, new_groups=1)
    release.add_project(project)
    commit_author1 = CommitAuthor.objects.create(name='stebe', email=email.email, organization_id=project.organization_id)
    commit_author2 = CommitAuthor.objects.create(name='stebe', email=otheremail.email, organization_id=project.organization_id)
    commit1 = Commit.objects.create(organization_id=project.organization_id, repository_id=1, key='abc', author=commit_author1, message='waddap')
    commit2 = Commit.objects.create(organization_id=project.organization_id, repository_id=1, key='cde', author=commit_author2, message='oh    hi')
    ReleaseCommit.objects.create(organization_id=project.organization_id, project_id=project.id, release=release, commit=commit1, order=1)
    ReleaseCommit.objects.create(organization_id=project.organization_id, project_id=project.id, release=release, commit=commit2, order=2)
    release.update(authors=[six.text_type(commit_author1.id), six.text_type(commit_author2.id)], commit_count=2, last_commit_id=commit2.id)
    result = serialize(release, user)
    assert (len(result['authors']) == 1)
    assert (result['authors'][0]['email'] == 'stebe@sentry.io')
