diff --git a/addon/-private/system/model/model.js b/addon/-private/system/model/model.js index 1fe2d3c5e13..cddcd8693f6 100644 --- a/addon/-private/system/model/model.js +++ b/addon/-private/system/model/model.js @@ -122,8 +122,8 @@ var Model = Ember.Object.extend(Ember.Evented, { @type {Boolean} @readOnly */ - hasDirtyAttributes: Ember.computed('currentState', function() { - return this.get('_internalModel.currentState.isDirty'); + hasDirtyAttributes: Ember.computed('currentState.isDirty', function() { + return this.get('currentState.isDirty'); }), /** If this property is `true` the record is in the `saving` state. A diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index 51285823bda..8953f59f7dc 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -420,7 +420,6 @@ Store = Service.extend({ */ unloadRecord(record) { record.unloadRecord(); - record.destroy(); }, // ................ @@ -1622,7 +1621,8 @@ Store = Service.extend({ for (let i = 0; i < records.length; i++) { record = records[i]; - this.unloadRecord(record); + record.unloadRecord(); + record.destroy(); // maybe within unloadRecord } typeMap.metadata = new EmptyObject(); diff --git a/tests/unit/store/unload-test.js b/tests/unit/store/unload-test.js index 2379bcb0477..f2a131ff676 100644 --- a/tests/unit/store/unload-test.js +++ b/tests/unit/store/unload-test.js @@ -66,7 +66,7 @@ testInDebug("unload a dirty record asserts", function(assert) { }); test("unload a record", function(assert) { - assert.expect(6); + assert.expect(5); run(function() { store.push({ @@ -87,7 +87,6 @@ test("unload a record", function(assert) { }); assert.equal(get(record, 'hasDirtyAttributes'), false, "record is not dirty"); - assert.equal(get(record, 'isDestroyed'), true, 'record is destroyed'); assert.equal(get(record, 'isDeleted'), true, "record is deleted"); tryToFind = false; @@ -98,42 +97,6 @@ test("unload a record", function(assert) { }); }); -test("unload a record - observers should be removed", function(assert) { - assert.expect(4); - - run(function() { - store.push({ - data: { - type: 'record', - id: '1', - attributes: { - title: 'toto' - } - } - }); - - store.findRecord('record', 1).then(function(record) { - Ember.addObserver(record, 'title', record, function() { - assert.ok(false, 'observer for record.title'); - }); - - let observers = Ember.observersFor(record, 'title'); - assert.equal(observers.length, 1, 'record should have 1 observer'); - - run(function() { - store.unloadRecord(record); - }); - - run(function() { - let observers = Ember.observersFor(record, 'title'); - assert.equal(get(record, 'isDeleted'), true, 'record is deleted'); - assert.equal(get(record, 'isDestroyed'), true, 'record is destroyed'); - assert.equal(observers.length, 0, 'record should not have observers'); - }); - }); - }); -}); - module("DS.Store - unload record with relationships");