Fix race condition where MyEmail model was not attached to the correct dataSource in tests

This commit is contained in:
Ritchie Martori 2014-01-23 14:25:54 -08:00
parent d6a4230aed
commit a43d6004c1
2 changed files with 10 additions and 5 deletions

View File

@ -83,10 +83,9 @@ MailConnector.prototype.transportForName = function(name) {
*/
MailConnector.prototype.defaultTransport = function() {
return this.transports[0];
return this.transports[0] || this.stubTransport;
}
/**
* Send an email with the given `options`.
*
@ -110,6 +109,8 @@ Mailer.send = function (options, fn) {
var dataSource = this.dataSource;
var settings = dataSource && dataSource.settings;
var connector = dataSource.connector;
assert(connector, 'Cannot send mail without a connector!');
var transport = connector.transportForName(options.transport);
if(!transport) {

View File

@ -1,8 +1,12 @@
var loopback = require('../');
var MyEmail = loopback.Email.extend('my-email');
var MyEmail;
var assert = require('assert');
describe('Email and SMTP', function () {
beforeEach(function() {
MyEmail = loopback.Email.extend('my-email');
loopback.autoAttach();
});
it('should have a send method', function () {
assert(typeof MyEmail.send === 'function');