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 20, 2015
1 parent 35c7cab commit 2de1770
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/ember-data/lib/system/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
keysFunc
} from 'ember-data/system/object-polyfills';

import computedPolyfill from "ember-new-computed";
var errorDeprecationShown = false;

/**
@module ember-data
*/
Expand Down Expand Up @@ -128,6 +131,22 @@ var Model = Ember.Object.extend(Ember.Evented, {
Ember.deprecate('DS.Model#isDirty has been deprecated please use hasDirtyAttributes instead');
return this.get('currentState.isDirty');
}),

/**
@property error
@type {Boolean}
@deprecated
*/
error: computedPolyfill({
get() {
if (!errorDeprecationShown) {
Ember.deprecate('DS.Model#error has been deprecated please use adapterError instead');
errorDeprecationShown = true;
}
return Ember.get(this, 'adapterError');
}
}),

/**
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
24 changes: 24 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,27 @@ test('isDirty should log a deprecation warning', function() {
}, /DS.Model#isDirty has been deprecated/);
});
});


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

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

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

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

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

0 comments on commit 2de1770

Please sign in to comment.