Permalink
Browse files

ready to test in a live environment

  • Loading branch information...
1 parent 4a0a673 commit cf0f87b7be5ba00a10ceccba18fbb2ad53c9fa61 @rizen committed Feb 9, 2014
Showing with 19 additions and 6 deletions.
  1. +5 −1 author.t/01_ifly.t
  2. +12 −3 lib/Chat/iFly.pm
  3. +2 −2 public/js/iflychat.js
View
@@ -16,14 +16,18 @@ isa_ok($chat, 'Chat::iFly');
is $chat->init()->{drupalchat}{exurl}, '/path/to/ajax/method', 'generate settings';
-say $chat->render_html();
+ok($chat->render_html =~ m{"exurl":"/path/to/ajax/method"}, 'generate html to embed in page');
ok($chat->fetch_anonymous_name, 'fetch anonymous name');
my $anonymous_user = $chat->generate_anonymous_user;
ok($anonymous_user->{id} =~ m/^0-\d+$/, '0-00000 to represent anonymous ids');
ok($anonymous_user->{name} =~ m/^Guest\s\w+$/, 'Guest Name to represent anonymous names');
+my $user_id = $anonymous_user->{id};
+ok($chat->render_ajax($anonymous_user) =~ m/$user_id/, 'generate ajax response');
+say $chat->render_ajax();
+
my $key = $chat->get_key($anonymous_user);
ok(exists $key->{key}, 'fetch a key');
View
@@ -301,6 +301,15 @@ sub render_html {
sub render_ajax {
my ($self, $user) = @_;
+ #my %defaults = (
+ # name => undef,
+ # id => 0,
+ # avatar_url => JSON::false,
+ # is_admin => JSON::false,
+ # relationships_set => JSON::false,
+ # upl => JSON::false,
+ #);
+ return to_json($self->get_key($user));
}
sub init {
@@ -447,7 +456,7 @@ sub get_key {
my $result = $self->post('/p/', {
api_key => $self->api_key,
uname => $user->{name},
- uid => $user->{id},
+ uid => $user->{id} || 0,
image_path => $self->static_asset_base_uri.'/themes/light/images',
isLog => JSON::true,
whichTheme => 'blue',
@@ -456,10 +465,10 @@ sub get_key {
validState => ['available','offline','busy','idle'],
up => (exists $user->{avatar_uri}) ? $user->{avatar_uri} : $self->static_asset_base_uri.'/themes/light/images/default_avatar.png',
upl => (exists $user->{profile_uri}) ? $user->{profile_uri} : '#',
- rel => (exists $user->{relationships_set}) ? 1 : 0,
+ rel => (exists $user->{relationships_set}) ? 1 : undef,
valid_uids => $user->{relationships_set},
});
- $result->{uid} = $user->{id};
+ $result->{uid} = $user->{id} || 0;
$result->{name} = $user->{name};
return $result;
}
View
@@ -6,7 +6,7 @@ b.urls[0]){l("css");break}h+=1;b&&(h<200?setTimeout(t,50):l("css"))}}var c,s,m={
$(document).ready(function(){
$.post(Drupal.settings.drupalchat.exurl, function(data) {
if(data) {
- data = JSON.parse(data);
+ // data = JSON.parse(data);
if(data && (typeof data.css != "undefined") && (typeof data.key != "undefined")) {
LazyLoad.css(Drupal.settings.drupalchat.external_a_host + ':' + Drupal.settings.drupalchat.external_a_port + '/i/' + data.css + '/cache.css', function () {
Drupal.settings.drupalchat.session_key = data.key;
@@ -26,4 +26,4 @@ b.urls[0]){l("css");break}h+=1;b&&(h<200?setTimeout(t,50):l("css"))}}var c,s,m={
}
});
});
-})(jQuery);
+})(jQuery);

0 comments on commit cf0f87b

Please sign in to comment.