master
1describe "AutoCollection", ->
2 subject = null
3 beforeEach ->
4 subject = csx.AutoCollection
5
6 describe ".install", ->
7 it "installs a categories collection", ->
8 subject.install('Category', 'categories', [id: 1, name: 'cakes'])
9
10 collection = csx.Collections.Category
11 expect(collection).not.toBe(undefined)
12 expect(collection.length).toEqual(1)
13 expect(collection.first().get('name')).toEqual('cakes')
14
15 it "binds the proper model", ->
16 subject.install('Category', 'categories', [])
17 expect(csx.Collections.Category.model).toEqual(csx.Models.Category)
18
19 it "binds the proper url", ->
20 subject.install('Cake', 'cakes', [])
21 expect(csx.Collections.Cake.url).toEqual('/api/v1/cakes')
22
23 it "works for models that do not map to a backbone model", ->
24 subject.install('Tag', 'acts_as_taggable_on_tags', [])
25 expect(csx.Collections.Tag.model).toEqual(Backbone.Model)
26 expect(csx.Collections.Tag.url).toEqual(undefined)