Sha256: 6dce243fe47c5b8ff06494d8bdbadb29106212137a8f1fe5e6d295c4031131c3

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 Bytes

Contents

root = exports ? window

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

describe 'model ( validates_associated: ... )',  ->

  describe 'basic usage', ->
    model  = root.model
    person = address = null

    beforeEach ->
      address = model.call
        resource : 'address'
        street   : String
        validates_presence_of: 'street'

      person = model.call
        resource : 'person'
        has_one  : 'address'
        validates_associated: 'address'

    afterEach ->
      person.validators.length  = 0
      address.validators.length = 0

    describe '.validate()', ->

      it 'should add error to record when fields does not match', ->
        arthur = person {}
        arthur.build_address street: null

        arthur.valid

        arthur.errors.messages.should.have.deep.property 'address', 'O registro associado address não é válido.'
        arthur.address.errors.messages.should.have.deep.property 'street', 'O campo street não pode ficar em branco.'

Version data entries

2 entries across 2 versions & 1 rubygems

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