Sha256: e759e2d5b13e49fa8fa5c4c7096ef4f6245935f1e7b9d6cc8451e15dfb688fdb

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

root = exports ? window

require 'indemma/lib/record/associable'

describe 'record',  ->
  record = root.record

  it 'should create a record'

describe 'model',  ->
  model  = root.model
  person = corporation = null

  beforeEach ->
    corporation = model.call
      resource: 'corporation'

    # TODO implement support for self referential associations
    friend = model.call
      resource: 'friends'

    person = model.call
      resource  : 'person'
      has_many  : 'friends'
      belongs_to: 'corporation'

  describe 'belongs_to', ->

    it 'should add builded object to association named attribute', ->
      arthur = person
        name: 'Arthur Dent'

      corporation = arthur.build_corporation()
      arthur.should.have.property 'corporation'
      expect(corporation).to.be.ok

  describe 'has_many', ->

    it 'should return a record factory with associations stored', ->
      person.has_many.should.be.array

      has_many = Array.prototype.splice.call person.has_many, 0

      has_many.should.contain 'friends'

    describe '#()', ->

      it 'should return a record with an association object', ->
        person().should.have.property 'friends'

      describe '{generated_association}', ->
        association = null

        beforeEach -> association = person().friends

        it 'should have query methods', ->
          association.should.have.property 'all'
          association.should.have.property 'each'
          association.should.have.property 'reload'

        describe '#all', ->

          it 'should auto observe nested associations attributes'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ende-0.2.3 vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee
ende-0.2.2 vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee
ende-0.2.1 vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee
ende-0.2.0 vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee