Skip to content

Commit

Permalink
Deprecate error property
Browse files Browse the repository at this point in the history
  • Loading branch information
tchak committed Jul 18, 2015
1 parent 35c7cab commit cd6acb1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/ember-data/lib/system/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var Model = Ember.Object.extend(Ember.Evented, {
Ember.deprecate('DS.Model#isDirty has been deprecated please use hasDirtyAttributes instead');
return this.get('currentState.isDirty');
}),

/**
If this property is `true` the record is in the `dirty` state. The
record has local changes that have not yet been saved by the
Expand Down Expand Up @@ -901,4 +902,18 @@ Model.reopenClass({
modelName: null
});

if (Ember.platform.hasPropertyAccessors) {
Ember.defineProperty(Model.prototype, 'error', {
enumerable: false,
get: function() {
Ember.deprecate('DS.Model#error has been deprecated please use adapterError instead');
return Ember.get(this, 'adapterError');
},
set: function(error) {
Ember.deprecate('DS.Model#error has been deprecated please use adapterError instead');
return Ember.set(this, 'adapterError', error);
}
});
}

export default Model;
27 changes: 27 additions & 0 deletions packages/ember-data/tests/unit/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,3 +923,30 @@ test('isDirty should log a deprecation warning', function() {
}, /DS.Model#isDirty has been deprecated/);
});
});


test('error should log a deprecation warning', function() {
expect(3);
var Person = DS.Model.extend({
});

var env = setupStore({
person: Person
});
var store = env.store;

run(function() {
var person = store.createRecord('person');
var error = {};

expectDeprecation(function() {
person.set('error', error);
}, /DS.Model#error has been deprecated/);

expectDeprecation(function() {
person.get('error');
}, /DS.Model#error has been deprecated/);

equal(person.get('error'), error, 'error should be set');
});
});

0 comments on commit cd6acb1

Please sign in to comment.