2016-06-28 21:13:01 +03:00
|
|
|
var sinon = require('sinon'),
|
2016-07-18 20:22:37 +03:00
|
|
|
mail = require('../../../server/mail'),
|
2016-06-28 21:13:01 +03:00
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
|
|
|
|
describe('Mail: Utils', function () {
|
|
|
|
var scope = {ghostMailer: null};
|
|
|
|
|
HTML newsletter template for subscribers (#7045)
refs #7023
The template can be used for all cases (different newsletter interval, different amount of blog posts, with or without blog picture).
The template can be filled with the following data structure:
- `blog.logo` is the blog logo from settings
- `blog.title` is the title of the current blog
- `blog.url` is the URL of the blog
- `blog.twitterURL` is the twitter profile URL of the blog from settings
- `blog.facebookURL` is the facebook page URL of the blog from settings
- `blog.unsubscribe` is the link for the reader to unsubscribe from the blog
- `newsletter.interval` is the interval in words like 'weekly', 'daily', 'monthly'
- `newsletter.date` is the date of the newsletter issue in a format like 'June 9th, 2016'
- `blog.post` is expected to be an array:
- `blog.post[i].picture` is the picture of the blog post. There are also conditionals, which change the inline CSS to either show a border-top if there's no picture (in that case the HTML code, that shows the picture is not active)
- `blog.post[i].title` is the title of the current blog post
- `blog.post[i].text` is the text of the current blog post, which needs to be cut down to 278 letters, plus ending with `…`
- `blog.post[i].url` is the URL of the current blog post
- `blog.post[i].tag` is the tag of the current blog post
- `blog.post[i].author` is the author of the current blog post
Important is, that only HEX HTML entities will work, especially in Outlook. So instead of `—` we need to use `—` and `’` instead of `'` or `'` and so on.
Added unit test for newsletter template in `test/unit/mail/utils_spec.js`.
2016-07-09 06:40:32 +03:00
|
|
|
beforeEach(function () {
|
2016-06-28 21:13:01 +03:00
|
|
|
scope.ghostMailer = new mail.GhostMailer();
|
|
|
|
|
|
|
|
sandbox.stub(scope.ghostMailer.transport, 'sendMail', function (message, sendMailDone) {
|
|
|
|
sendMailDone(null, {
|
|
|
|
statusHandler: {
|
|
|
|
once: function (eventName, eventDone) {
|
|
|
|
if (eventName === 'sent') {
|
|
|
|
eventDone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
HTML newsletter template for subscribers (#7045)
refs #7023
The template can be used for all cases (different newsletter interval, different amount of blog posts, with or without blog picture).
The template can be filled with the following data structure:
- `blog.logo` is the blog logo from settings
- `blog.title` is the title of the current blog
- `blog.url` is the URL of the blog
- `blog.twitterURL` is the twitter profile URL of the blog from settings
- `blog.facebookURL` is the facebook page URL of the blog from settings
- `blog.unsubscribe` is the link for the reader to unsubscribe from the blog
- `newsletter.interval` is the interval in words like 'weekly', 'daily', 'monthly'
- `newsletter.date` is the date of the newsletter issue in a format like 'June 9th, 2016'
- `blog.post` is expected to be an array:
- `blog.post[i].picture` is the picture of the blog post. There are also conditionals, which change the inline CSS to either show a border-top if there's no picture (in that case the HTML code, that shows the picture is not active)
- `blog.post[i].title` is the title of the current blog post
- `blog.post[i].text` is the text of the current blog post, which needs to be cut down to 278 letters, plus ending with `…`
- `blog.post[i].url` is the URL of the current blog post
- `blog.post[i].tag` is the tag of the current blog post
- `blog.post[i].author` is the author of the current blog post
Important is, that only HEX HTML entities will work, especially in Outlook. So instead of `—` we need to use `—` and `’` instead of `'` or `'` and so on.
Added unit test for newsletter template in `test/unit/mail/utils_spec.js`.
2016-07-09 06:40:32 +03:00
|
|
|
afterEach(function () {
|
2016-06-28 21:13:01 +03:00
|
|
|
sandbox.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('generate welcome', function (done) {
|
|
|
|
mail.utils.generateContent({
|
|
|
|
template: 'welcome',
|
|
|
|
data: {
|
2016-10-03 17:11:43 +03:00
|
|
|
ownerEmail: 'test@example.com'
|
2016-06-28 21:13:01 +03:00
|
|
|
}
|
|
|
|
}).then(function (result) {
|
|
|
|
return scope.ghostMailer.send({
|
2016-10-03 17:11:43 +03:00
|
|
|
to: 'test@example.com',
|
2016-06-28 21:13:01 +03:00
|
|
|
subject: 'lol',
|
|
|
|
html: result.html,
|
|
|
|
text: result.text
|
|
|
|
});
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
}).catch(done);
|
|
|
|
});
|
HTML newsletter template for subscribers (#7045)
refs #7023
The template can be used for all cases (different newsletter interval, different amount of blog posts, with or without blog picture).
The template can be filled with the following data structure:
- `blog.logo` is the blog logo from settings
- `blog.title` is the title of the current blog
- `blog.url` is the URL of the blog
- `blog.twitterURL` is the twitter profile URL of the blog from settings
- `blog.facebookURL` is the facebook page URL of the blog from settings
- `blog.unsubscribe` is the link for the reader to unsubscribe from the blog
- `newsletter.interval` is the interval in words like 'weekly', 'daily', 'monthly'
- `newsletter.date` is the date of the newsletter issue in a format like 'June 9th, 2016'
- `blog.post` is expected to be an array:
- `blog.post[i].picture` is the picture of the blog post. There are also conditionals, which change the inline CSS to either show a border-top if there's no picture (in that case the HTML code, that shows the picture is not active)
- `blog.post[i].title` is the title of the current blog post
- `blog.post[i].text` is the text of the current blog post, which needs to be cut down to 278 letters, plus ending with `…`
- `blog.post[i].url` is the URL of the current blog post
- `blog.post[i].tag` is the tag of the current blog post
- `blog.post[i].author` is the author of the current blog post
Important is, that only HEX HTML entities will work, especially in Outlook. So instead of `—` we need to use `—` and `’` instead of `'` or `'` and so on.
Added unit test for newsletter template in `test/unit/mail/utils_spec.js`.
2016-07-09 06:40:32 +03:00
|
|
|
|
|
|
|
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({
|
2016-10-03 17:11:43 +03:00
|
|
|
to: 'jbloggs@example.com',
|
HTML newsletter template for subscribers (#7045)
refs #7023
The template can be used for all cases (different newsletter interval, different amount of blog posts, with or without blog picture).
The template can be filled with the following data structure:
- `blog.logo` is the blog logo from settings
- `blog.title` is the title of the current blog
- `blog.url` is the URL of the blog
- `blog.twitterURL` is the twitter profile URL of the blog from settings
- `blog.facebookURL` is the facebook page URL of the blog from settings
- `blog.unsubscribe` is the link for the reader to unsubscribe from the blog
- `newsletter.interval` is the interval in words like 'weekly', 'daily', 'monthly'
- `newsletter.date` is the date of the newsletter issue in a format like 'June 9th, 2016'
- `blog.post` is expected to be an array:
- `blog.post[i].picture` is the picture of the blog post. There are also conditionals, which change the inline CSS to either show a border-top if there's no picture (in that case the HTML code, that shows the picture is not active)
- `blog.post[i].title` is the title of the current blog post
- `blog.post[i].text` is the text of the current blog post, which needs to be cut down to 278 letters, plus ending with `…`
- `blog.post[i].url` is the URL of the current blog post
- `blog.post[i].tag` is the tag of the current blog post
- `blog.post[i].author` is the author of the current blog post
Important is, that only HEX HTML entities will work, especially in Outlook. So instead of `—` we need to use `—` and `’` instead of `'` or `'` and so on.
Added unit test for newsletter template in `test/unit/mail/utils_spec.js`.
2016-07-09 06:40:32 +03:00
|
|
|
subject: 'The Newsletter Blog',
|
|
|
|
html: result.html,
|
|
|
|
text: result.text
|
|
|
|
});
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
}).catch(done);
|
|
|
|
});
|
2016-06-28 21:13:01 +03:00
|
|
|
});
|