Skip to content

Instantly share code, notes, and snippets.

@dlikhten
Created March 17, 2012 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlikhten/2055740 to your computer and use it in GitHub Desktop.
Save dlikhten/2055740 to your computer and use it in GitHub Desktop.
Problem with Backbone Relational (issue 72)
var Location = Backbone.RelationalModel.extend({
});
var LocatableA = Backbone.RelationalModel.extend({
relations: [{
type: "HasMany",
key: 'locations',
relatedModel: Location,
reverseRelation: {
key: 'locatable'
}
}]
});
var LocatableB = Backbone.RelationalModel.extend({
relations: [{
type: "HasMany",
key: 'locations',
relatedModel: Location,
reverseRelation: {
key: 'locatable'
}
}]
});
describe("BackboneRelational", function() {
it("should associate correctly", function() {
var la = new LocatableA({
locations: [{
id: 1,
label: "Foo"
}]
});
var lb = new LocatableB({
locations: [{
id: 1,
label: "Foo"
}]
});
expect(la.get('locations').length).toEqual(1);
expect(lb.get('locations').length).toEqual(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment