Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Commit

Permalink
Fix to make it work in unit-test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Henning committed Oct 27, 2016
1 parent 3371f90 commit 7aa35bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const factory = (options) => {
// `preview` prop in the data context to apply to the layout.
if (tmpl.__helpers.has('preview')) {
preview = tmpl.__helpers.get('preview');
} else if (data.preview) {
} else if (data && data.preview) { // data is optional
preview = data.preview;
}

Expand Down
16 changes: 15 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,21 @@ Utils = {
},

readFile(relativePathFromApp) {
const file = Path.join(ROOT, relativePathFromApp);
let file
if (Meteor.isAppTest
|| Meteor.isTest) {
// note:
// * this DOES WORK with Meteor.isTest (=unit test mode)
// * Meteor.isAppTest is NOT TESTED yet (=in-app test mode)
//
// background-info: we had NO luck with "Assets.absoluteFilePath(relativePathFromApp)",
// so lets build the path ourselves.
// see discussion https://github.com/lookback/meteor-emails/issues/76
file = Path.join(process.cwd(), 'assets', 'app', relativePathFromApp)
} else {
// = standard mode (development || production)
file = Path.join(ROOT, relativePathFromApp);
}

try {
return fs.readFileSync(file, {
Expand Down

0 comments on commit 7aa35bf

Please sign in to comment.