'The shortcut view (used for the admin "view on site" functionality)
returns a complete URL regardless of whether the sites framework is
installed.'

@override_settings(ALLOWED_HOSTS=['example.com'])
def test_shortcut_view(self):

    request = HttpRequest()
    request.META = {'SERVER_NAME': 'Example.com', 'SERVER_PORT': '80'}
    user_ct = ContentType.objects.get_for_model(FooWithUrl)
    obj = FooWithUrl.objects.create(name='john')
    with self.modify_settings(INSTALLED_APPS={'append': 'django.contrib.sites'}):
        response = shortcut(request, user_ct.id, obj.id)
        self.assertEqual(('http://%s/users/john/' % get_current_site(request).domain), response._headers.get('location')[1])
    with self.modify_settings(INSTALLED_APPS={'remove': 'django.contrib.sites'}):
        response = shortcut(request, user_ct.id, obj.id)
        self.assertEqual('http://Example.com/users/john/', response._headers.get('location')[1])
