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

[FEATURE ds-references] More conistency for RecordReference #4009

Merged
merged 1 commit into from
Dec 17, 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
13 changes: 10 additions & 3 deletions addon/-private/system/references/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ import Reference from './reference';
var RecordReference = function(store, internalModel) {
this._super$constructor(store, internalModel);
this.type = internalModel.modelName;
this.id = internalModel.id;
this.remoteType = 'identity';
this._id = internalModel.id;
};

RecordReference.prototype = Object.create(Reference.prototype);
RecordReference.prototype.constructor = RecordReference;
RecordReference.prototype._super$constructor = Reference;

RecordReference.prototype.id = function() {
return this._id;
};

RecordReference.prototype.remoteType = function() {
return 'identity';
};

RecordReference.prototype.push = function(objectOrPromise) {
return Ember.RSVP.resolve(objectOrPromise).then((data) => {
var record = this.store.push(data);
Expand All @@ -24,7 +31,7 @@ RecordReference.prototype.value = function() {
};

RecordReference.prototype.load = function() {
return this.store.findRecord(this.type, this.id);
return this.store.findRecord(this.type, this._id);
};

RecordReference.prototype.reload = function() {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/references/record-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ if (isEnabled("ds-references")) {
test("a RecordReference can be retrieved via store.getReference(type, id)", function(assert) {
var recordReference = env.store.getReference('person', 1);

assert.equal(recordReference.remoteType, 'identity');
assert.equal(recordReference.remoteType(), 'identity');
assert.equal(recordReference.type, 'person');
assert.equal(recordReference.id, 1);
assert.equal(recordReference.id(), 1);
});

test("push(object)", function(assert) {
Expand Down