'If we detect a duplicate email when confirming an email change,
don\'t change it and notify the user.'

@mock.patch.object(Site.objects, 'get_current')
def test_user_confirm_email_duplicate(self, get_current):

    get_current.return_value.domain = 'su.mo.com'
    old_email = self.user.email
    new_email = 'newvalid@email.com'
    response = self.client.post(reverse('users.change_email'), {'email': new_email})
    eq_(200, response.status_code)
    assert (mail.outbox[0].subject.find('Please    confirm    your') == 0)
    ec = EmailChange.objects.all()[0]
    u = UserFactory(email=new_email)
    response = self.client.get(reverse('users.confirm_email', args=[ec.activation_key]))
    eq_(200, response.status_code)
    doc = pq(response.content)
    eq_((u'Unable    to    change    email    for    user    %s' % self.user.username), doc('article    h1').text())
    u = User.objects.get(username=self.user.username)
    eq_(old_email, u.email)
