Created
March 17, 2012 06:22
-
-
Save dlikhten/2055740 to your computer and use it in GitHub Desktop.
Problem with Backbone Relational (issue 72)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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