Permalink
Browse files

sending jade email

  • Loading branch information...
1 parent 529e019 commit 8cfcc0e12a68efcba0568e126320c4e44c7baf0c @garrensmith committed Apr 18, 2011
Showing with 18 additions and 11 deletions.
  1. +5 −2 lib/index.js
  2. +5 −5 spec/fixtures/email.jade
  3. +8 −4 spec/sendmail_spec.js
View
@@ -30,7 +30,6 @@ var Madmimi = module.exports = function (username, api_key, debug) {
requestOptions.headers = {'content-type': 'application/x-www-form-urlencoded'};
}
-
if(!cb) { cb = function () {} };
var httpBody = undefined
@@ -69,6 +68,8 @@ var Madmimi = module.exports = function (username, api_key, debug) {
function _sendMail(options, cb) {
optionsParameterized = querystring.stringify(options, "&", "=");
+
+ console.dir(options);
var requestOptions = {
host: 'api.madmimi.com',
@@ -85,7 +86,9 @@ var Madmimi = module.exports = function (username, api_key, debug) {
options.api_key = self.api_key;
if (options.jade) {
- jade.renderFile('path/to/some.jade', function(err, html){
+ jade.renderFile(options.jade, function(err, html){
+ if(err) throw err;
+
delete options.jade;
options.raw_html = html;
_sendMail(options, cb);
View
@@ -1,7 +1,7 @@
!!! 5
-
head
- title= Great promotion!
-
-body
- | Cool guitar stuff [[tracking_beacon]]
+ title= "Great promotion!"
+
+body
+ p
+ | Cool guitar stuff [[tracking_beacon]]
View
@@ -44,14 +44,18 @@ describe("Render Jade").
}).
it("Should render to html", function (async) {
madmimi.request = async(function (requestOptions, body) {
- body.should().beEqual('promotion_name=Test%20Promotion&recipient=Jimi%20Hendrix%20%3Cjimi%40electricladyland.com%3E&subject=Test%20Promotion&from=no-reply%40guitargear.com&raw_html=%3Chtml%3E%3Chead%3E%3Ctitle%3EGreat%20promotion!%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3ECool%20guitar%20stuff%5B%5Btracking_beacon%5D%5D%3C%2Fbody%3E%3C%2Fhtml%3E&username=fake%40email.com&api_key=fake-api-key');
-
+ body.should().beEqual("promotion_name=Test%20Promotion&recipient=Jimi%20Hendrix%20%3Cjimi%40electricladyland.com%3E&subject=Test%20Promotion&from=no-reply%40guitargear.com&username=fake%40email.com&api_key=fake-api-key&raw_html=%3C!DOCTYPE%20html%3E%3Chead%3E%3Ctitle%3EGreat%20promotion!%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3E%3Cp%3ECool%20guitar%20stuff%20%5B%5Btracking_beacon%5D%5D%0A%3C%2Fp%3E%3C%2Fbody%3E");
});
- var options = email_options;
- delete options.raw_html;
+ var options = {
+ promotion_name:"Test Promotion",
+ recipient:"Jimi Hendrix <jimi@electricladyland.com>",
+ subject:"Test Promotion",
+ from:"no-reply@guitargear.com",
+ };
+
options.jade = process.cwd() + '/spec/fixtures/email.jade';

0 comments on commit 8cfcc0e

Please sign in to comment.