diff --git a/package.json b/package.json index 962f6ea2..98bbb7a7 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,9 @@ "istanbul": "^0.4.2", "mocha": "^2.4.5", "mysql": "^2.10.2", + "semantic-release": "^4.3.5", "sqlite3": "^3.1.1", - "standard": "^6.0.5", - "semantic-release": "^4.3.5" + "standard": "^6.0.5" }, "config": { "commitizen": { diff --git a/src/Lucid/Model/Mixins/Hooks.js b/src/Lucid/Model/Mixins/Hooks.js index e6f2c21e..34816335 100644 --- a/src/Lucid/Model/Mixins/Hooks.js +++ b/src/Lucid/Model/Mixins/Hooks.js @@ -79,7 +79,7 @@ Hooks.composeHooks = function (scope, hooks) { Hooks.executeInsertHooks = function * (scope, insertHandler) { let handlerResult = null const insertHandlerWrapper = function * (next) { - handlerResult = yield insertHandler.bind(this) + handlerResult = yield insertHandler.call(this) yield next } const hooksChain = this.getHooks('Create', insertHandlerWrapper) @@ -102,7 +102,7 @@ Hooks.executeInsertHooks = function * (scope, insertHandler) { Hooks.executeUpdateHooks = function * (scope, updateHandler) { let handlerResult = null const updateHandlerWrapper = function * (next) { - handlerResult = yield updateHandler.bind(this) + handlerResult = yield updateHandler.call(this) yield next } const hooksChain = this.getHooks('Update', updateHandlerWrapper) @@ -125,7 +125,7 @@ Hooks.executeUpdateHooks = function * (scope, updateHandler) { Hooks.executeDeleteHooks = function * (scope, deleteHandler) { let handlerResult = null const deleteHandlerWrapper = function * (next) { - handlerResult = yield deleteHandler.bind(this) + handlerResult = yield deleteHandler.call(this) yield next } const hooksChain = this.getHooks('Delete', deleteHandlerWrapper) diff --git a/test/unit/lucid.relations.spec.js b/test/unit/lucid.relations.spec.js index 30f1dac4..ee103302 100644 --- a/test/unit/lucid.relations.spec.js +++ b/test/unit/lucid.relations.spec.js @@ -700,7 +700,7 @@ describe('Relations', function () { yield relationFixtures.truncate(Database, 'profiles') }) - it('should be able to save related model instance', function * () { + it('should be able to save related model instance', function * (done) { class Account extends Model { } class Supplier extends Model { @@ -718,6 +718,7 @@ describe('Relations', function () { expect(account.supplier_id).to.equal(supplier.id) yield relationFixtures.truncate(Database, 'suppliers') yield relationFixtures.truncate(Database, 'accounts') + done() }) it('should throw an when save object is not an instance of related model', function * () {