diff --git a/core/test/unit/migration_fixture_spec.js b/core/test/unit/migration_fixture_spec.js index 32931f1070..0a815f7fbe 100644 --- a/core/test/unit/migration_fixture_spec.js +++ b/core/test/unit/migration_fixture_spec.js @@ -1014,10 +1014,6 @@ describe('Fixtures', function () { sandbox.stub(Date.prototype, 'getTimezoneOffset', function () { return serverTimezoneOffset; }); - - sandbox.stub(models.Settings, 'findOne', function () { - return Promise.resolve({attributes: {value: migrationsSettingsValue}}); - }); }); describe('error cases', function () { @@ -1025,6 +1021,12 @@ describe('Fixtures', function () { serverTimezoneOffset = 0; }); + beforeEach(function () { + sandbox.stub(models.Settings, 'findOne', function () { + return Promise.resolve({attributes: {value: migrationsSettingsValue}}); + }); + }); + it('server offset is 0', function (done) { migrationsSettingsValue = '{}'; @@ -1080,21 +1082,25 @@ describe('Fixtures', function () { return Promise.resolve({}); }); - sandbox.stub(models.Base.Model, 'findAll', function () { - var model = models.Base.Model.forge(); - model.set('id', Date.now()); - model.set('created_at', createdAt); - model.set('key', model.id.toString()); + _.each(['Post', 'User', 'Subscriber', 'Settings', 'Role', 'Permission', 'Tag', 'App', 'AppSetting', 'AppField', 'Client'], function (modelType) { + sandbox.stub(models[modelType], 'findAll', function () { + var model = models[modelType].forge(); + model.set('id', Date.now()); + model.set('created_at', createdAt); + model.set('key', model.id.toString()); - newModels[model.id] = model; - return Promise.resolve({models: [model]}); + newModels[model.id] = model; + return Promise.resolve({models: [model]}); + }); + + if (modelType !== 'Settings') { + sandbox.stub(models[modelType], 'findOne', function (data) { + return Promise.resolve(newModels[data.id]); + }); + } + + sandbox.stub(models[modelType], 'edit').returns(Promise.resolve({})); }); - - sandbox.stub(models.Base.Model, 'findOne', function (data) { - return Promise.resolve(newModels[data.id]); - }); - - sandbox.stub(models.Base.Model, 'edit').returns(Promise.resolve({})); }); it('sqlite: no UTC update, only format', function (done) { diff --git a/package.json b/package.json index 976041ed99..481b02e405 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "bcryptjs": "2.3.0", "bluebird": "3.4.1", "body-parser": "1.15.1", - "bookshelf": "0.9.5", + "bookshelf": "https://github.com/acburdine/bookshelf#master-built", "chalk": "1.1.3", "cheerio": "0.20.0", "compression": "1.6.2",