Merge pull request #37 from greenkahuna/master

Fixes default name key for intercom.
This commit is contained in:
Joost Cassee 2014-05-01 17:01:07 +02:00
commit 60c2d03c50
3 changed files with 9 additions and 9 deletions

View file

@ -10,6 +10,6 @@ Django_ project. See the ``docs`` directory for more information.
__author__ = "Joost Cassee"
__email__ = "joost@cassee.net"
__version__ = "0.17.0"
__version__ = "0.17.1"
__copyright__ = "Copyright (C) 2011-2012 Joost Cassee and others"
__license__ = "MIT License"

View file

@ -59,8 +59,8 @@ class IntercomNode(Node):
user = get_user_from_context(context)
if user is not None and user.is_authenticated():
if 'full_name' not in vars:
vars['full_name'] = get_identity(context, 'intercom', self._identify, user)
if 'name' not in vars:
vars['name'] = get_identity(context, 'intercom', self._identify, user)
if 'email' not in vars and user.email:
vars['email'] = user.email

View file

@ -36,7 +36,7 @@ class IntercomTagTestCase(TagTestCase):
# Because the json isn't predictably ordered, we can't just test the whole thing verbatim.
self.assertEquals("""
<script id="IntercomSettingsScriptTag">
window.intercomSettings = {"app_id": "1234567890abcdef0123456789", "created_at": 1397074500, "email": "test@example.com", "full_name": "Firstname Lastname"};
window.intercomSettings = {"app_id": "1234567890abcdef0123456789", "created_at": 1397074500, "email": "test@example.com", "name": "Firstname Lastname"};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://static.intercomcdn.com/intercom.v1.js';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
""", rendered_tag)
@ -55,7 +55,7 @@ class IntercomTagTestCase(TagTestCase):
first_name='Firstname', last_name='Lastname',
email="test@example.com", date_joined=now)}))
self.assertTrue(
"""window.intercomSettings = {"app_id": "1234567890abcdef0123456789", "created_at": 1397074500, "email": "test@example.com", "full_name": "Firstname Lastname"};"""\
"""window.intercomSettings = {"app_id": "1234567890abcdef0123456789", "created_at": 1397074500, "email": "test@example.com", "name": "Firstname Lastname"};"""\
in r
)
@ -73,16 +73,16 @@ class IntercomTagTestCase(TagTestCase):
last_name='Lastname',
email="test@example.com")
}))
self.assertTrue('"email": "test@example.com", "full_name": "Firstname Lastname"' in r)
self.assertTrue('"email": "test@example.com", "name": "Firstname Lastname"' in r)
def test_identify_username_no_email(self):
r = IntercomNode().render(Context({'user': User(username='test')}))
self.assertTrue('"full_name": "test"' in r, r)
self.assertTrue('"name": "test"' in r, r)
def test_no_identify_when_explicit_name(self):
r = IntercomNode().render(Context({'intercom_full_name': 'explicit',
r = IntercomNode().render(Context({'intercom_name': 'explicit',
'user': User(username='implicit')}))
self.assertTrue('"full_name": "explicit"' in r, r)
self.assertTrue('"name": "explicit"' in r, r)
def test_no_identify_when_explicit_email(self):
r = IntercomNode().render(Context({'intercom_email': 'explicit',