Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate error property #3560

Merged
merged 1 commit into from
Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('adapterError', {
get() {
if (!errorDeprecationShown) {
Ember.deprecate('DS.Model#error has been deprecated please use adapterError instead');
errorDeprecationShown = true;
}
return Ember.get(this, 'adapterError');
}
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this computed need a dependency on adapterError or should it be marked volatile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off cours... Sorry for the mess with this thing. Should have been an easy one. Updated...


/**
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');
});
});