Sha256: 34ac1fee44eb9ae4bcc72d6780e93d11f6cb52601649c822fc028d6bc867f88a

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

root = exports ? window

require 'indemma/lib/record/persistable.js'

describe 'persistable',  ->

  describe 'model', ->
    it 'should set the persistable key', ->
      model.should.have.property 'persistable', true

    describe '#find', ->
      beforeEach ->
        @xhr = jQuery.Deferred()
        sinon.stub(jQuery, "ajax").returns @xhr

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

        @arthur = @personable
          name: 'Arthur Philip Dent'

        @xhr.resolveWith @arthur, [_id: 1]

        # TODO use another way to check if record has persisted
        @arthur.dirty = true

      afterEach  -> jQuery.ajax.restore()

      it 'should try to store a record after saving when initialzed without id', (done) ->
        sinon.stub(@personable.storage, 'store').returns true

        @arthur.save =>
          expect(@personable.storage.store.calledOnce).to.be.true
          done()

        @personable.storage.store.restore()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ende-0.5.22 components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee
ende-0.5.21 components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee