diff --git a/addon/initializer.js b/addon/initializer.js index 43dc55d..1e9fae3 100644 --- a/addon/initializer.js +++ b/addon/initializer.js @@ -1,4 +1,4 @@ /* global require */ export function initializer() { require('ember-data-change-tracker/model-ext'); -} \ No newline at end of file +} diff --git a/addon/model-ext.js b/addon/model-ext.js index bf58a9a..8cff4a0 100644 --- a/addon/model-ext.js +++ b/addon/model-ext.js @@ -118,4 +118,4 @@ Model.reopen({ Tracker.clear(this); }) -}); \ No newline at end of file +}); diff --git a/tests/unit/model-test.js b/tests/unit/model-test.js index 1eac106..2e85967 100644 --- a/tests/unit/model-test.js +++ b/tests/unit/model-test.js @@ -1,4 +1,6 @@ import Ember from 'ember'; +const {run} = Ember; + import FactoryGuy, { build, make, makeList, mockUpdate, mockFindRecord, mockReload, mockDelete, manualSetup, mockSetup, mockTeardown @@ -251,6 +253,22 @@ test('#changed ( modifying ) attribute of type undefined', function(assert) { assert.ok(changed); }); +test('#changed ( modifying ) attribute of type undefined then saveChanges', function(assert) { + let company = make('company', { name: 'blu' }), + changed; + company.startTrack(); + + run(() => { + company.set('name', 'bla'); + company.saveChanges(); + //if we run twice the below, the test passes.. + //company._internalModel.flushChangedAttributes(); + //company._internalModel.flushChangedAttributes(); + changed = company.changed().name; + assert.notOk(changed); + }); +}); + test('#changed ( modifying ) attribute of type that does not serialize to string', function(assert) { let blob = { foo: 1 }; let user = make('user', { blob });