+
+
+
+
+
+
+
+
+
+
+
+ <% if (blog.logo) { %>
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+ <% } %>
+
+
+
+
+
+
+
+
+
+
+
+ {{blog.title}}
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{newsletter.interval}} digest —
+ {{newsletter.date}}
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+ <% if (blog.post[0].picture) { %>
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+ <% } %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <% if (blog.post[0].picture) { %>
+
+ <% } else { %>
+
+ <% } %>
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{blog.post[0].text}}
+
+ |
+
+
+ |
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+ <% if (blog.post.length > 1) { %>
+
+
+
+
+
+ |
+
+
+
+
+
+
+ {{blog.post[1].tag}} / {{blog.post[1].author}}
+
+
+
+
+
+
+
+ {{blog.post[1].text}}
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+ <% if (blog.post.length > 2) { %>
+
+
+
+
+
+ |
+
+
+
+
+
+
+ {{blog.post[2].tag}} / {{blog.post[2].author}}
+
+
+
+
+
+
+
+ {{blog.post[2].text}}
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+ <% if (blog.post.length > 3) { %>
+
+ <% for (var i = 3; i < blog.post.length; i++) { %>
+
+
+
+
+
+ |
+
+
+
+
+
+
+ {{blog.post[i]['tag']}} / {{blog.post[i]['author']}}
+
+
+
+
+
+
+
+ {{blog.post[i]['text']}}
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+ <% if (i < blog.post.length-1) { %>
+
+ <% } %>
+
+ <% } %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ or follow us on
+ Twitter &
+ Facebook
+ for instant updates
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+ <% } %>
+
+ <% } %>
+
+ <% } %>
+
+
+
+
+
+
+
+
+
+
+
+ You’re receiving this email because you subscribed to {{newsletter.interval}} emails from {{blog.title}} If you’d prefer not to receive these, you can
+
+ unsubscribe instantly
+ .
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
diff --git a/core/test/unit/mail/utils_spec.js b/core/test/unit/mail/utils_spec.js
index f433a2a6d8..468d57fec1 100644
--- a/core/test/unit/mail/utils_spec.js
+++ b/core/test/unit/mail/utils_spec.js
@@ -5,7 +5,7 @@ var sinon = require('sinon'),
describe('Mail: Utils', function () {
var scope = {ghostMailer: null};
- before(function () {
+ beforeEach(function () {
scope.ghostMailer = new mail.GhostMailer();
sandbox.stub(scope.ghostMailer.transport, 'sendMail', function (message, sendMailDone) {
@@ -21,7 +21,7 @@ describe('Mail: Utils', function () {
});
});
- after(function () {
+ afterEach(function () {
sandbox.restore();
});
@@ -42,4 +42,75 @@ describe('Mail: Utils', function () {
done();
}).catch(done);
});
+
+ it('generates newsletter template', function (done) {
+ mail.utils.generateContent({
+ template: 'newsletter',
+ data: {
+ blog: {
+ logo: 'http://myblog.com/content/images/blog-logo.jpg',
+ title: 'The Ghost Blog',
+ url: 'http://myblog.com',
+ twitterUrl: 'http://twitter.com/tryghost',
+ facebookUrl: 'https://www.facebook.com/ghost',
+ unsubscribe: 'http://myblog.com/unsubscribe',
+ post: [
+ {
+ picture: 'http://myblog.com/content/images/post-1-image.jpg',
+ title: 'Featured blog post',
+ text: 'This is a featured blog post. It’s awesome…',
+ url: 'http://myblog.com/featured-blog-post',
+ tag: 'featured',
+ author: 'harry potter'
+ },
+ {
+ picture: 'http://myblog.com/content/images/post-2-image.jpg',
+ title: 'Second blog post',
+ text: 'This is the second blog post. It’s also awesome…',
+ url: 'http://myblog.com/second-blog-post',
+ tag: 'second',
+ author: 'lord voldemord'
+ },
+ {
+ picture: 'http://myblog.com/content/images/post-3-image.jpg',
+ title: 'Third blog post',
+ text: 'This is the third blog post. It’s also awesome…',
+ url: 'http://myblog.com/third-blog-post',
+ tag: 'third',
+ author: 'marry poppins'
+ },
+ {
+ picture: 'http://myblog.com/content/images/post-4-image.jpg',
+ title: 'Fourth blog post',
+ text: 'This is the fourth blog post. It’s also awesome…',
+ url: 'http://myblog.com/fourth-blog-post',
+ tag: 'fourth',
+ author: 'donald duck'
+ },
+ {
+ picture: 'http://myblog.com/content/images/post-5-image.jpg',
+ title: 'Fifth blog post',
+ text: 'This is the fifth blog post. It’s also awesome…',
+ url: 'http://myblog.com/fifth-blog-post',
+ tag: 'fifth',
+ author: 'casper the ghost'
+ }
+ ]
+ },
+ newsletter: {
+ interval: 'monthly',
+ date: 'june, 9th 2016'
+ }
+ }
+ }).then(function (result) {
+ return scope.ghostMailer.send({
+ to: 'aileen@ghost.org',
+ subject: 'The Newsletter Blog',
+ html: result.html,
+ text: result.text
+ });
+ }).then(function () {
+ done();
+ }).catch(done);
+ });
});
|