Skip to content

Commit

Permalink
Update auto_email lib to send Google Calendar invits + bundling of wa…
Browse files Browse the repository at this point in the history
…tches #35
  • Loading branch information
MathieuNls committed Feb 3, 2016
1 parent 98d29d1 commit 5041d74
Show file tree
Hide file tree
Showing 9 changed files with 391 additions and 89 deletions.
268 changes: 218 additions & 50 deletions application/libraries/Auto_email.php

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions application/tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
*
* NOTE: If you change these, also change the error_reporting() code below
*/
// This is needed for @runInSeparateProcess
if (! defined('ENVIRONMENT'))
{
define('ENVIRONMENT', 'testing');
}

define('ENVIRONMENT', 'testing');


/*
*---------------------------------------------------------------
Expand Down
25 changes: 4 additions & 21 deletions application/tests/libraries/Auto_email_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ public function setUp() {
$mandrillMessage->method('reschedule')->willReturn($returnReschedule);
$mandrillMessage->method('cancelScheduled')->willReturn($returnSend);

$CI->load->library('auto_email');
$CI->load->model('Watch');
$CI->load->model('Measure');
$CI->load->library('auto_email');

$CI->auto_email->CI->mandrill->messages = $mandrillMessage;
$CI->auto_email->CI->mcapi = $mcapi;

$this->email = $CI->auto_email;
$this->watchModel = $CI->Watch;
$this->email = $CI->auto_email;
$this->watchModel = $CI->Watch;
$this->measureModel = $CI->Measure;
}

Expand Down Expand Up @@ -352,7 +352,6 @@ public function test_startANewMeasure(){

$this->assertEquals($emails['watches'][0]['emailType'],
$this->email->START_NEW_MEASURE);

$this->assertEquals($emails['watches'][0]['content'],
$startNewMeasureContent);

Expand Down Expand Up @@ -389,24 +388,18 @@ public function test_comback(){

$this->assertEquals($emails['users'][1]['userId'], self::$users['ernest']->userId);
$this->assertEquals($emails['users'][1]['emailType'], $this->email->COMEBACK);
$this->assertEquals($emails['users'][1]['content'], $comebackContent);


$this->assertEquals($emails['users'][2]['userId'], self::$users['anatole']->userId);
$this->assertEquals($emails['users'][2]['emailType'], $this->email->COMEBACK);
$this->assertEquals($emails['users'][2]['content'], $comebackContent);

$this->assertEquals($emails['users'][3]['userId'], self::$users['phillibert']->userId);
$this->assertEquals($emails['users'][3]['emailType'], $this->email->COMEBACK);
$this->assertEquals($emails['users'][3]['content'], $comebackContent);

$this->assertEquals($emails['users'][4]['userId'], self::$users['hippolyte']->userId);
$this->assertEquals($emails['users'][4]['emailType'], $this->email->COMEBACK);
$this->assertEquals($emails['users'][4]['content'], $comebackContent);

$this->assertEquals($emails['users'][5]['userId'], self::$users['raymond']->userId);
$this->assertEquals($emails['users'][5]['emailType'], $this->email->COMEBACK);
$this->assertEquals($emails['users'][5]['content'], $comebackContent);

//Check that the email is sent only once
$emails = $this->email->cronCheck(101*25*60*60);
Expand Down Expand Up @@ -436,21 +429,11 @@ public function test_addFirstMeasure(){
//The watch is added at time() + 24*39*61*60
$emails = $this->email->cronCheck(102*25*60*60);

$addFirstMeasureContent = file_get_contents("emails/add_first_measure.html",
FILE_USE_INCLUDE_PATH);

$this->assertEquals(sizeof($emails['users']), 0);
$this->assertEquals(sizeof($emails['watches']), 1);
$this->assertEquals(sizeof($emails['watches']), 0);
$this->assertEquals(sizeof($emails['measures']), 0);

$this->assertEquals($emails['watches'][0]['watchId'],
self::$watchId);

$this->assertEquals($emails['watches'][0]['emailType'],
$this->email->START_FIRST_MEASURE);

$this->assertEquals($emails['watches'][0]['content'],
$addFirstMeasureContent);

//Check that the email is sent only once
$emails = $this->email->cronCheck(24*1*62*60);
Expand Down
32 changes: 31 additions & 1 deletion application/tests/libraries/emails/add_second_watch.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,37 @@ <h1 style="display:block;margin:0;padding:0;color:#202020;font-family:Helvetica;
<tr>
<td valign="top" style="background-color:#fafafa;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px"><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">

</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td valign="top">


<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">
<tbody><tr>

<td style="padding-top:9px;padding-left:18px;padding-bottom:9px;padding-right:18px">

<table border="0" cellpadding="18" cellspacing="0" width="100%" style="min-width:100%!important;background-color:#eeeeee;border-collapse:collapse">
<tbody><tr>
<td valign="top" style="color:#000000;font-family:Helvetica;font-size:14px;font-weight:normal;text-align:left;word-break:break-word;line-height:150%">
<div style="text-align:center">Quick view of your Toolwatch <a href="https://toolwatch.io/measures/?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwath dashboard" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">dashboard</a> :</div>

<ul> <li><span style="color:#000000;font-family:monospace;font-size:medium;line-height:normal;white-space:pre-wrap"><img goomoji="231a" data-goomoji="231a" style="margin:0 0.2ex;vertical-align:middle;max-height:24px" alt="" src="https://mail.google.com/mail/e/231a" class="CToWUd"> rolex marolex: Check accuracy in 12 hours.</span></li>
</ul>
Have you tested your watch recently? Measure it <a href="https://toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">NO</a><a href="https://Toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">W</a>!
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>



</td>
</tr>
</tbody>
</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td style="min-width:100%;padding:9px 18px">
Expand Down
36 changes: 33 additions & 3 deletions application/tests/libraries/emails/check_accuracy.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<h1 style="display:block;margin:0;padding:0;color:#202020;font-family:Helvetica;font-size:26px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left">Hey nay!</h1>
&nbsp;

<p style="text-align:justify;margin:10px 0;padding:0;color:#202020;font-family:Helvetica;font-size:16px;line-height:150%">You've synchronized your rolex marolex with
Toolwatch one day ago and now is the time to see the results
<p style="text-align:justify;margin:10px 0;padding:0;color:#202020;font-family:Helvetica;font-size:16px;line-height:150%">One day ago, you've synchronized the following watch(es): <ul><li>rolex marolex</li></ul> with
Toolwatch and now is the time to see the results
of your watch's accuracy !<br>
Just make sure your have your watch(es) near you (it should already
be on your wrist ;) ) and go to the
Expand Down Expand Up @@ -83,7 +83,37 @@ <h1 style="display:block;margin:0;padding:0;color:#202020;font-family:Helvetica;
<tr>
<td valign="top" style="background-color:#fafafa;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px"><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">

</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td valign="top">


<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">
<tbody><tr>

<td style="padding-top:9px;padding-left:18px;padding-bottom:9px;padding-right:18px">

<table border="0" cellpadding="18" cellspacing="0" width="100%" style="min-width:100%!important;background-color:#eeeeee;border-collapse:collapse">
<tbody><tr>
<td valign="top" style="color:#000000;font-family:Helvetica;font-size:14px;font-weight:normal;text-align:left;word-break:break-word;line-height:150%">
<div style="text-align:center">Quick view of your Toolwatch <a href="https://toolwatch.io/measures/?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwath dashboard" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">dashboard</a> :</div>

<ul> <li><span style="color:#000000;font-family:monospace;font-size:medium;line-height:normal;white-space:pre-wrap"><img goomoji="231a" data-goomoji="231a" style="margin:0 0.2ex;vertical-align:middle;max-height:24px" alt="" src="https://mail.google.com/mail/e/231a" class="CToWUd"> rolex marolex: Check accuracy in 12 hours.</span></li>
</ul>
Have you tested your watch recently? Measure it <a href="https://toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">NO</a><a href="https://Toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">W</a>!
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>



</td>
</tr>
</tbody>
</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td style="min-width:100%;padding:9px 18px">
Expand Down
36 changes: 33 additions & 3 deletions application/tests/libraries/emails/check_accuracy_1w.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<h1 style="display:block;margin:0;padding:0;color:#202020;font-family:Helvetica;font-size:26px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left">Hey nay!</h1>
&nbsp;

<p style="text-align:justify;margin:10px 0;padding:0;color:#202020;font-family:Helvetica;font-size:16px;line-height:150%">You've synchronized your rolex marolex with
Toolwatch one week ago and now is the time to see the results
<p style="text-align:justify;margin:10px 0;padding:0;color:#202020;font-family:Helvetica;font-size:16px;line-height:150%">One week ago, you've synchronized the following watch(es): <ul><li>rolex marolex</li></ul> with
Toolwatch and now is the time to see the results
of your watch's accuracy !<br>
Just make sure your have your watch(es) near you (it should already
be on your wrist ;) ) and go to the
Expand Down Expand Up @@ -83,7 +83,37 @@ <h1 style="display:block;margin:0;padding:0;color:#202020;font-family:Helvetica;
<tr>
<td valign="top" style="background-color:#fafafa;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px"><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">

</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td valign="top">


<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">
<tbody><tr>

<td style="padding-top:9px;padding-left:18px;padding-bottom:9px;padding-right:18px">

<table border="0" cellpadding="18" cellspacing="0" width="100%" style="min-width:100%!important;background-color:#eeeeee;border-collapse:collapse">
<tbody><tr>
<td valign="top" style="color:#000000;font-family:Helvetica;font-size:14px;font-weight:normal;text-align:left;word-break:break-word;line-height:150%">
<div style="text-align:center">Quick view of your Toolwatch <a href="https://toolwatch.io/measures/?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwath dashboard" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">dashboard</a> :</div>

<ul> <li><span style="color:#000000;font-family:monospace;font-size:medium;line-height:normal;white-space:pre-wrap"><img goomoji="231a" data-goomoji="231a" style="margin:0 0.2ex;vertical-align:middle;max-height:24px" alt="" src="https://mail.google.com/mail/e/231a" class="CToWUd"> rolex marolex: Check accuracy in 12 hours.</span></li>
</ul>
Have you tested your watch recently? Measure it <a href="https://toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">NO</a><a href="https://Toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">W</a>!
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>



</td>
</tr>
</tbody>
</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td style="min-width:100%;padding:9px 18px">
Expand Down
32 changes: 31 additions & 1 deletion application/tests/libraries/emails/comeback.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,37 @@ <h1 style="display:block;margin:0;padding:0;color:#202020;font-family:Helvetica;
<tr>
<td valign="top" style="background-color:#fafafa;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px"><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">

</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td valign="top">


<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse">
<tbody><tr>

<td style="padding-top:9px;padding-left:18px;padding-bottom:9px;padding-right:18px">

<table border="0" cellpadding="18" cellspacing="0" width="100%" style="min-width:100%!important;background-color:#eeeeee;border-collapse:collapse">
<tbody><tr>
<td valign="top" style="color:#000000;font-family:Helvetica;font-size:14px;font-weight:normal;text-align:left;word-break:break-word;line-height:150%">
<div style="text-align:center">Quick view of your Toolwatch <a href="https://toolwatch.io/measures/?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwath dashboard" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">dashboard</a> :</div>

<ul> <li><span style="color:#000000;font-family:monospace;font-size:medium;line-height:normal;white-space:pre-wrap"><img goomoji="231a" data-goomoji="231a" style="margin:0 0.2ex;vertical-align:middle;max-height:24px" alt="" src="https://mail.google.com/mail/e/231a" class="CToWUd"> rolex marolex: Runs at 0.0 spd (-8 day(s) ago).</span></li>
</ul>
Have you tested your watch recently? Measure it <a href="https://toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">NO</a><a href="https://Toolwatch.io?utm_source=Toolwatch+blog&amp;utm_campaign=e1c9cc363f-Toolwatch_Test&amp;utm_medium=email&amp;utm_term=0_73aaa65a62-e1c9cc363f-" title="Toolwatch.io" style="color:#656565;font-weight:normal;text-decoration:underline" target="_blank">W</a>!
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>



</td>
</tr>
</tbody>
</table><table border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;border-collapse:collapse;table-layout:fixed!important">
<tbody>
<tr>
<td style="min-width:100%;padding:9px 18px">
Expand Down
Loading

0 comments on commit 5041d74

Please sign in to comment.