Skip to content

Instantly share code, notes, and snippets.

@gmoeck
Created June 5, 2011 01:55
Show Gist options
  • Save gmoeck/1008573 to your computer and use it in GitHub Desktop.
Save gmoeck/1008573 to your computer and use it in GitHub Desktop.
Onetoone.Model1 = SC.Record.extend(
model1Value: SC.Record.attr(String, {}),
model2: SC.Record.toOne('Onetoone.Model2', {inverse:'model1', isMaster: NO})
}) ;
Onetoone.Model2 = SC.Record.extend(
model2Value: SC.Record.attr(String, {}),
model1: SC.Record.toOne('Onetoone.Model1')
}) ;
var model1Instance, model2Instance;
module("Onetoone.Model1", {
setup: function() {
Onetoone.store.loadRecord(Onetoone.Model2, {guid: 'model2-1', model2Id:1, model2Value:'value2', model1:'model1-1'});
Onetoone.store.loadRecord(Onetoone.Model1, {guid: 'model1-1', model1Id:1, model1Value:'value1', model2: 'model2-1'});
model1Instance = Onetoone.store.find(Onetoone.Model1, 'model1-1');
model2Instance = Onetoone.store.find(Onetoone.Model2, 'model2-1');
}
});
test("testModel2Property", function() {
equals(model2Instance.get('model1'), model1Instance, "Model1 should be available from model2");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment