ende 0.5.20 → 0.5.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +1 -1
- data/components/indefinido/indemma/master/.gitignore +17 -0
- data/components/indefinido/indemma/master/.ruby-gemset +1 -0
- data/components/indefinido/indemma/master/.ruby-version +1 -0
- data/components/indefinido/indemma/master/Gemfile +12 -0
- data/components/indefinido/indemma/master/Guardfile +39 -0
- data/components/indefinido/indemma/master/History.md +0 -0
- data/components/indefinido/indemma/master/Readme.md +445 -0
- data/components/indefinido/indemma/master/build/development.js +26123 -0
- data/components/indefinido/indemma/master/build/release.js +16741 -0
- data/components/indefinido/indemma/master/build/test.js +26123 -0
- data/components/indefinido/indemma/master/component.json +1 -1
- data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/component.json +18 -0
- data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/index.js +110 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.gitignore +22 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.mailmap +1 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.npmignore +14 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.travis.yml +14 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/CONTRIBUTING.md +173 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/History.md +895 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/Makefile +93 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/README.md +99 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/ReleaseNotes.md +482 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/bower.json +27 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/chai.js +4782 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/component.json +50 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/index.js +1 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.conf.js +28 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.sauce.js +41 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/assertion.js +130 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/config.js +50 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/core/assertions.js +1314 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/assert.js +1056 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/expect.js +12 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/should.js +78 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addChainableMethod.js +111 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addMethod.js +43 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addProperty.js +40 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/flag.js +32 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getActual.js +18 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getMessage.js +49 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getName.js +20 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getPathValue.js +102 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getProperties.js +35 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/index.js +114 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/inspect.js +320 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/objDisplay.js +49 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteChainableMethod.js +53 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteMethod.js +51 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteProperty.js +54 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/test.js +26 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/transferFlags.js +44 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/type.js +45 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai.js +87 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/package.json +42 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/sauce.browsers.js +128 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_block.sh +7 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_setup.sh +53 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/assert.js +638 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/auth/.gitkeep +0 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/index.js +22 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/karma.js +22 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/configuration.js +133 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/errors.js +14 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/message.js +47 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/expect.js +814 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/globalShould.js +15 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/plugins.js +24 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/should.js +744 -0
- data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/utilities.js +309 -0
- data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/component.json +20 -0
- data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/lib/eql.js +257 -0
- data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/component.json +18 -0
- data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/lib/type.js +142 -0
- data/components/indefinido/indemma/master/components/component/bind/1.0.0/component.json +14 -0
- data/components/indefinido/indemma/master/components/component/bind/1.0.0/index.js +23 -0
- data/components/indefinido/indemma/master/components/component/jquery/1.0.0/component.json +10 -0
- data/components/indefinido/indemma/master/components/component/jquery/1.0.0/index.js +10308 -0
- data/components/indefinido/indemma/master/components/component/type/1.0.0/component.json +20 -0
- data/components/indefinido/indemma/master/components/component/type/1.0.0/index.js +32 -0
- data/components/indefinido/indemma/master/components/indefinido/advisable/master/component.json +21 -0
- data/components/indefinido/indemma/master/components/indefinido/advisable/master/index.js +1 -0
- data/components/indefinido/indemma/master/components/indefinido/advisable/master/lib/advisable.js +60 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/component.json +39 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/index.js +1 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/adapters/rivets.js +40 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/notifierable.js +145 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +147 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/lookup.js +38 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/keypath_observer.js +38 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/observation.js +45 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/selection.js +57 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/self_observer.js +38 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable.js +97 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/platform.js +12 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/observe-js/observe.js +1631 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors-legacy.js +92 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors.js +248 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/array.indexOf.js +8 -0
- data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/object.create.js +77 -0
- data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/component.json +25 -0
- data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/dist/assimilate.js +127 -0
- data/components/indefinido/indemma/master/karma.conf.js +75 -0
- data/components/indefinido/indemma/master/lib/record/associable.js +4 -2
- data/components/indefinido/indemma/master/lib/record/dirtyable.js +1 -1
- data/components/indefinido/indemma/master/package.json +9 -0
- data/components/indefinido/indemma/master/spec/record/associable_spec.js +211 -0
- data/components/indefinido/indemma/master/spec/record/dirtyable_spec.js +57 -0
- data/components/indefinido/indemma/master/spec/record/maid_spec.js +40 -0
- data/components/indefinido/indemma/master/spec/record/persistable_spec.js +46 -0
- data/components/indefinido/indemma/master/spec/record/queryable_spec.js +39 -0
- data/components/indefinido/indemma/master/spec/record/resource_spec.js +93 -0
- data/components/indefinido/indemma/master/spec/record/rest_spec.js +32 -0
- data/components/indefinido/indemma/master/spec/record/restfulable_spec.js +346 -0
- data/components/indefinido/indemma/master/spec/record/scopable_spec.js +242 -0
- data/components/indefinido/indemma/master/spec/record/storable_spec.js +44 -0
- data/components/indefinido/indemma/master/spec/record/translationable.js +28 -0
- data/components/indefinido/indemma/master/spec/record/validatable_spec.js +142 -0
- data/components/indefinido/indemma/master/spec/record/validations/associated_spec.js +43 -0
- data/components/indefinido/indemma/master/spec/record/validations/confirmation_spec.js +36 -0
- data/components/indefinido/indemma/master/spec/record/validations/cpf_spec.js +34 -0
- data/components/indefinido/indemma/master/spec/record/validations/presence_spec.js +28 -0
- data/components/indefinido/indemma/master/spec/record/validations/remote_spec.js +87 -0
- data/components/indefinido/indemma/master/spec/record/validations/type_spec.js +48 -0
- data/components/indefinido/indemma/master/spec/record_spec.js +49 -0
- data/components/indefinido/indemma/master/spec/spec_helper.js +15 -0
- data/components/indefinido/indemma/master/spec/support/value_objects/phone.js +45 -0
- data/components/indefinido/indemma/master/src/lib/extensions/rivets.coffee +17 -0
- data/components/indefinido/indemma/master/src/lib/record/associable.coffee +419 -0
- data/components/indefinido/indemma/master/src/lib/record/dirtyable.coffee +47 -0
- data/components/indefinido/indemma/master/src/lib/record/errors.coffee +20 -0
- data/components/indefinido/indemma/master/src/lib/record/maid.coffee +16 -0
- data/components/indefinido/indemma/master/src/lib/record/persistable.coffee +34 -0
- data/components/indefinido/indemma/master/src/lib/record/queryable.coffee +29 -0
- data/components/indefinido/indemma/master/src/lib/record/resource.coffee +107 -0
- data/components/indefinido/indemma/master/src/lib/record/rest.coffee +34 -0
- data/components/indefinido/indemma/master/src/lib/record/restfulable.coffee +487 -0
- data/components/indefinido/indemma/master/src/lib/record/scopable.coffee +279 -0
- data/components/indefinido/indemma/master/src/lib/record/storable.coffee +49 -0
- data/components/indefinido/indemma/master/src/lib/record/translationable.coffee +18 -0
- data/components/indefinido/indemma/master/src/lib/record/validatable.coffee +241 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/associated.coffee +34 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/confirmation.coffee +17 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/cpf.coffee +57 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/presence.coffee +16 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/remote.coffee +61 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/type.coffee +31 -0
- data/components/indefinido/indemma/master/src/lib/record/validations/validatorable.coffee +5 -0
- data/components/indefinido/indemma/master/src/lib/record.coffee +143 -0
- data/components/indefinido/indemma/master/src/spec/record/associable_spec.coffee +205 -0
- data/components/indefinido/indemma/master/src/spec/record/dirtyable_spec.coffee +47 -0
- data/components/indefinido/indemma/master/src/spec/record/maid_spec.coffee +34 -0
- data/components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee +39 -0
- data/components/indefinido/indemma/master/src/spec/record/queryable_spec.coffee +33 -0
- data/components/indefinido/indemma/master/src/spec/record/resource_spec.coffee +69 -0
- data/components/indefinido/indemma/master/src/spec/record/rest_spec.coffee +22 -0
- data/components/indefinido/indemma/master/src/spec/record/restfulable_spec.coffee +257 -0
- data/components/indefinido/indemma/master/src/spec/record/scopable_spec.coffee +227 -0
- data/components/indefinido/indemma/master/src/spec/record/storable_spec.coffee +39 -0
- data/components/indefinido/indemma/master/src/spec/record/translationable.coffee +19 -0
- data/components/indefinido/indemma/master/src/spec/record/validatable_spec.coffee +127 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/associated_spec.coffee +35 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee +25 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/cpf_spec.coffee +27 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/presence_spec.coffee +24 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/remote_spec.coffee +74 -0
- data/components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee +33 -0
- data/components/indefinido/indemma/master/src/spec/record_spec.coffee +29 -0
- data/components/indefinido/indemma/master/src/spec/spec_helper.coffee +11 -0
- data/components/indefinido/indemma/master/src/spec/support/value_objects/phone.coffee +30 -0
- data/components/indefinido/indemma/master/vendor/object/mixin.js +196 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/assert.js +199 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/behavior.js +334 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/call.js +205 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/collection.js +155 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/match.js +245 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/mock.js +451 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/sandbox.js +144 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/spy.js +413 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/stub.js +161 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/test.js +77 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/test_case.js +99 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/event.js +94 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server.js +212 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server_with_clock.js +83 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_timers.js +405 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xdomain_request.js +206 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xml_http_request.js +575 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/timers_ie.js +31 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/xdr_ie.js +14 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon/util/xhr_ie.js +19 -0
- data/components/indefinido/indemma/master/vendor/spec/sinon.js +383 -0
- data/lib/assets/javascripts/value_objects/phone.js.coffee +3 -1
- data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +5 -5
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.css +4 -4
- data/vendor/assets/components/ende_build.js +7974 -7889
- metadata +191 -5
- data/vendor/assets/component/build.css +0 -112
- data/vendor/assets/components/build.css +0 -112
- data/vendor/assets/components/indemma_with_none.js +0 -30553
@@ -0,0 +1,35 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
require 'indemma/lib/record/validatable.js'
|
4
|
+
|
5
|
+
describe 'model ( validates_associated: ... )', ->
|
6
|
+
|
7
|
+
describe 'basic usage', ->
|
8
|
+
model = root.model
|
9
|
+
person = address = null
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
address = model.call
|
13
|
+
resource : 'address'
|
14
|
+
street : String
|
15
|
+
validates_presence_of: 'street'
|
16
|
+
|
17
|
+
person = model.call
|
18
|
+
resource : 'person'
|
19
|
+
has_one : 'address'
|
20
|
+
validates_associated: 'address'
|
21
|
+
|
22
|
+
afterEach ->
|
23
|
+
person.validators.length = 0
|
24
|
+
address.validators.length = 0
|
25
|
+
|
26
|
+
describe '.validate()', ->
|
27
|
+
|
28
|
+
it 'should add error to record when fields does not match', ->
|
29
|
+
arthur = person {}
|
30
|
+
arthur.build_address street: null
|
31
|
+
|
32
|
+
arthur.valid
|
33
|
+
|
34
|
+
arthur.errors.messages.should.have.deep.property 'address', 'O registro associado address não é válido.'
|
35
|
+
arthur.address.errors.messages.should.have.deep.property 'street', 'O campo street não pode ficar em branco.'
|
data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
require 'indemma/lib/record/validatable.js'
|
4
|
+
|
5
|
+
describe 'model #() validates_confirmation_of', ->
|
6
|
+
|
7
|
+
describe 'basic usage', ->
|
8
|
+
model = root.model
|
9
|
+
person = null
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
person = model.call
|
13
|
+
resource : 'person'
|
14
|
+
password : String
|
15
|
+
validates_confirmation_of: 'password'
|
16
|
+
|
17
|
+
afterEach ->
|
18
|
+
person.validators.length = 0
|
19
|
+
|
20
|
+
describe '#validate', ->
|
21
|
+
|
22
|
+
it 'should add error to record when fields does not match', ->
|
23
|
+
arthur = person password: "domo", password_confirmation: "kun"
|
24
|
+
arthur.valid
|
25
|
+
arthur.errors.messages.should.have.deep.property 'password_confirmation', 'O campo password não está de acordo com o campo password_confirmation.'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
require 'indemma/lib/record/validatable.js'
|
4
|
+
|
5
|
+
describe 'model #() validates_cpf_format', ->
|
6
|
+
|
7
|
+
describe 'basic usage', ->
|
8
|
+
model = root.model
|
9
|
+
|
10
|
+
beforeEach ->
|
11
|
+
@person = model.call
|
12
|
+
resource : 'person'
|
13
|
+
cpf : String
|
14
|
+
validates_cpf_format: 'cpf'
|
15
|
+
|
16
|
+
afterEach ->
|
17
|
+
# Clear validators from resource
|
18
|
+
@person.validators.length = 0
|
19
|
+
|
20
|
+
describe '#validate', ->
|
21
|
+
|
22
|
+
it 'should add error to record when fields is in invalid format', ->
|
23
|
+
arthur = @person cpf: '871.95FRANGO-00'
|
24
|
+
arthur.valid
|
25
|
+
|
26
|
+
# TODO figure out why the heck the validators aren't being reset
|
27
|
+
arthur.errors.messages.should.have.deep.property 'cpf', "O campo cpf não está válido."
|
@@ -0,0 +1,24 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
require 'indemma/lib/record/validatable.js'
|
4
|
+
|
5
|
+
describe 'model #() validates presence of', ->
|
6
|
+
|
7
|
+
describe 'basic usage', ->
|
8
|
+
model = root.model
|
9
|
+
person = null
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
person = model.call
|
13
|
+
resource : 'person'
|
14
|
+
name : String
|
15
|
+
belongs_to: 'corporation'
|
16
|
+
validates_presence_of: 'name'
|
17
|
+
|
18
|
+
afterEach ->
|
19
|
+
person.validators.length = 0
|
20
|
+
|
21
|
+
describe '#validate', ->
|
22
|
+
|
23
|
+
it 'should add error to record when required field is empty (null, undefined or \'\')'
|
24
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
require 'indemma/lib/record/validatable.js'
|
4
|
+
|
5
|
+
describe 'model #() validates_remotely', ->
|
6
|
+
model = root.model
|
7
|
+
request = arthur = person = null
|
8
|
+
|
9
|
+
describe 'basic usage', ->
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
person = model.call
|
13
|
+
resource : 'person'
|
14
|
+
name : String
|
15
|
+
validates_remotely: 'name'
|
16
|
+
|
17
|
+
arthur = person name: "Arthur Dent"
|
18
|
+
|
19
|
+
afterEach ->
|
20
|
+
person?.validators.length = 0
|
21
|
+
|
22
|
+
describe '#validate', ->
|
23
|
+
|
24
|
+
beforeEach ->
|
25
|
+
request = jQuery.Deferred()
|
26
|
+
sinon.stub(jQuery, "ajax").returns(request)
|
27
|
+
|
28
|
+
afterEach -> jQuery.ajax.restore()
|
29
|
+
|
30
|
+
it 'should send paramenters accordingly', ->
|
31
|
+
arthur.validate()
|
32
|
+
|
33
|
+
jQuery.ajax.called.should.be.true
|
34
|
+
|
35
|
+
jQuery.ajax.calledWithMatch(
|
36
|
+
url: '/people/validate'
|
37
|
+
type: 'post'
|
38
|
+
data:
|
39
|
+
person:
|
40
|
+
name: 'Arthur Dent'
|
41
|
+
).should.be.true
|
42
|
+
|
43
|
+
|
44
|
+
it 'should add errors to record when request responds with errors', ->
|
45
|
+
arthur.validate()
|
46
|
+
request.resolveWith arthur,
|
47
|
+
[name: ['The name should be Marvin!', 'The name should be in lowercase!']]
|
48
|
+
|
49
|
+
arthur.errors.length.should.be.eq 2
|
50
|
+
arthur.errors.messages.name.should.exist
|
51
|
+
|
52
|
+
describe 'with options usage', ->
|
53
|
+
|
54
|
+
beforeEach ->
|
55
|
+
person?.validators.length = 0
|
56
|
+
|
57
|
+
person = model.call
|
58
|
+
resource : 'person'
|
59
|
+
name : String
|
60
|
+
validates_remotely: 'name'
|
61
|
+
|
62
|
+
arthur = person name: "Arthur Dent"
|
63
|
+
|
64
|
+
describe '#validate', ->
|
65
|
+
|
66
|
+
beforeEach ->
|
67
|
+
request = jQuery.Deferred()
|
68
|
+
sinon.stub(jQuery, "ajax").returns(request)
|
69
|
+
|
70
|
+
afterEach -> jQuery.ajax.restore()
|
71
|
+
|
72
|
+
it 'should make ajax call', ->
|
73
|
+
arthur.validate()
|
74
|
+
jQuery.ajax.called.should.be.true
|
@@ -0,0 +1,33 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
require 'indemma/lib/record/validatable.js'
|
4
|
+
|
5
|
+
describe 'model #() validates type of', ->
|
6
|
+
|
7
|
+
describe 'basic usage', ->
|
8
|
+
model = root.model
|
9
|
+
person = null
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
person = model.call
|
13
|
+
resource : 'person'
|
14
|
+
name : String
|
15
|
+
phone : Phone
|
16
|
+
validates_type_of: ['name', 'phone']
|
17
|
+
|
18
|
+
afterEach ->
|
19
|
+
person.validators.length = 0
|
20
|
+
|
21
|
+
describe '#validate', ->
|
22
|
+
|
23
|
+
#it 'should use Phone#valid getter to find out if object is valid'
|
24
|
+
it 'should use Phone#validate to find out if attribute is valid'
|
25
|
+
it 'should add error to record when phone typed attribute has an non valid phone value', ->
|
26
|
+
arthur = person phone: new Phone 'batata'
|
27
|
+
arthur.valid.should.be.false
|
28
|
+
arthur.errors.messages.should.have.property 'phone'
|
29
|
+
expect(arthur.errors.messages.phone).to.match /não está válido/
|
30
|
+
|
31
|
+
it 'should throw error to when phone typed attribute has an non phone value', ->
|
32
|
+
arthur = person phone: 'batata'
|
33
|
+
expect( -> arthur.valid).to.throw /invalid attribute value type/i
|
@@ -0,0 +1,29 @@
|
|
1
|
+
root = exports ? window
|
2
|
+
|
3
|
+
describe 'record', ->
|
4
|
+
record = root.record
|
5
|
+
|
6
|
+
it 'should create a record', ->
|
7
|
+
arthur = record.call resource: 'person'
|
8
|
+
arthur.should.be.object
|
9
|
+
|
10
|
+
describe 'model', ->
|
11
|
+
model = root.model
|
12
|
+
|
13
|
+
describe '#()', ->
|
14
|
+
|
15
|
+
xit 'should throw exception if no resource is passed'
|
16
|
+
|
17
|
+
it 'should create a resource factory', ->
|
18
|
+
person = model.call resource: 'person'
|
19
|
+
person.should.be.object
|
20
|
+
|
21
|
+
john = person()
|
22
|
+
john.should.be.object
|
23
|
+
john.resource.should.have.property 'name', 'person'
|
24
|
+
|
25
|
+
it 'should execute after mix callbacks', (done) ->
|
26
|
+
|
27
|
+
person = model.call
|
28
|
+
resource: 'person'
|
29
|
+
after_mix: [-> done()]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# TODO locales support
|
2
|
+
class @Phone
|
3
|
+
|
4
|
+
constructor: (@area_code, @number) ->
|
5
|
+
{@area_code, @number} = @area_code if typeof @area_code == 'object'
|
6
|
+
|
7
|
+
|
8
|
+
# TODO parse argument types to validate value object domain
|
9
|
+
# constraints
|
10
|
+
|
11
|
+
unless @number
|
12
|
+
@number = @area_code
|
13
|
+
@area_code = null
|
14
|
+
|
15
|
+
Object.defineProperty @, 'valid', get: @validate
|
16
|
+
|
17
|
+
# TODO move type validation to indemma files
|
18
|
+
validate: -> @area_code? && @number?
|
19
|
+
|
20
|
+
toString: ->
|
21
|
+
formatted_number = @number.substr(0, 4) + '-' + @number.substr(4) if @number?
|
22
|
+
|
23
|
+
if @area_code?
|
24
|
+
"(#{@area_code}) #{formatted_number}"
|
25
|
+
else
|
26
|
+
formatted_number
|
27
|
+
|
28
|
+
toJSON: ->
|
29
|
+
area_code: @area_code
|
30
|
+
number: @number
|
@@ -0,0 +1,196 @@
|
|
1
|
+
/*jslint browser: true, forin: true, plusplus: true, indent: 4 */
|
2
|
+
(function(Object, mixin) {
|
3
|
+
"use strict"; // happy linter ^_____^
|
4
|
+
|
5
|
+
/* <droppable> interesting code after line 110, here
|
6
|
+
* ad-hoc polyfill section for this purpose only
|
7
|
+
* never use these functions outside this closure ... like ...
|
8
|
+
ne*/var
|
9
|
+
|
10
|
+
// borrowed methods for unknown Objects
|
11
|
+
ObjectPrototype = Object.prototype,
|
12
|
+
|
13
|
+
lookupGetter = ObjectPrototype.__lookupGetter__,
|
14
|
+
lookupSetter = ObjectPrototype.__lookupSetter__,
|
15
|
+
defineGetter = ObjectPrototype.__defineGetter__,
|
16
|
+
defineSetter = ObjectPrototype.__defineSetter__,
|
17
|
+
has = ObjectPrototype.hasOwnProperty,
|
18
|
+
|
19
|
+
emptyArray = [],
|
20
|
+
// slice = emptyArray.slice,
|
21
|
+
|
22
|
+
// for IE < 9 and non IE5 yet browsers
|
23
|
+
goNative = true,
|
24
|
+
defineProperty = (function(defineProperty){
|
25
|
+
try{
|
26
|
+
return defineProperty && defineProperty({},'_',{value:1})._ && defineProperty;
|
27
|
+
} catch(IE8) {
|
28
|
+
goNative = false;
|
29
|
+
}
|
30
|
+
}(Object.defineProperty)) ||
|
31
|
+
function (o, k, d) {
|
32
|
+
var
|
33
|
+
get = d.get, // has.call(d, 'get') would be better but
|
34
|
+
set = d.set; // ES5 is just like this
|
35
|
+
if (get && defineGetter) {
|
36
|
+
defineGetter.call(o, k, get);
|
37
|
+
}
|
38
|
+
if (set && defineSetter) {
|
39
|
+
defineSetter.call(o, k, set);
|
40
|
+
}
|
41
|
+
if (!(get || set)) {
|
42
|
+
o[k] = d.value;
|
43
|
+
}
|
44
|
+
},
|
45
|
+
// for IE < 9 and non IE5 yet browsers
|
46
|
+
getOwnPropertyNames = (goNative && Object.getOwnPropertyNames) ||
|
47
|
+
(function () {
|
48
|
+
var
|
49
|
+
addHiddenOwnProperties = function (result) {
|
50
|
+
return result;
|
51
|
+
},
|
52
|
+
list = [],
|
53
|
+
key,
|
54
|
+
i,
|
55
|
+
length;
|
56
|
+
|
57
|
+
for (key in {valueOf: key}) {
|
58
|
+
list.push(key);
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!list.length) {
|
62
|
+
length = list.push(
|
63
|
+
'constructor',
|
64
|
+
'hasOwnProperty',
|
65
|
+
'isPrototypeOf',
|
66
|
+
'propertyIsEnumerable',
|
67
|
+
'toLocaleString',
|
68
|
+
'toString',
|
69
|
+
'valueOf'
|
70
|
+
) - 1;
|
71
|
+
addHiddenOwnProperties = function (result, o) {
|
72
|
+
for (i = 0; i < length; i++) {
|
73
|
+
key = list[i];
|
74
|
+
if (has.call(o, key)) {
|
75
|
+
result.push(key);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
return result;
|
79
|
+
};
|
80
|
+
}
|
81
|
+
|
82
|
+
return function (o) {
|
83
|
+
var
|
84
|
+
result = [],
|
85
|
+
key;
|
86
|
+
for (key in o) {
|
87
|
+
if (has.call(o, key)) {
|
88
|
+
result.push(key);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
return addHiddenOwnProperties(result, o);
|
92
|
+
};
|
93
|
+
}()),
|
94
|
+
// IE < 9 or other non ES5 yet browsers
|
95
|
+
getOwnPropertyDescriptor = (goNative && Object.getOwnPropertyDescriptor) ||
|
96
|
+
function (o, k) {
|
97
|
+
var
|
98
|
+
descriptor = {
|
99
|
+
enumerable: true,
|
100
|
+
configurable: true
|
101
|
+
},
|
102
|
+
get = lookupGetter && lookupGetter.call(o, k),
|
103
|
+
set = lookupSetter && lookupSetter.call(o, k);
|
104
|
+
if (get) {
|
105
|
+
descriptor.get = get;
|
106
|
+
}
|
107
|
+
if (set) {
|
108
|
+
descriptor.set = set;
|
109
|
+
}
|
110
|
+
if (!(get || set)) {
|
111
|
+
descriptor.writable = true;
|
112
|
+
descriptor.value = o[k];
|
113
|
+
}
|
114
|
+
return descriptor;
|
115
|
+
};
|
116
|
+
// </droppable>
|
117
|
+
|
118
|
+
// if already defined get out of here
|
119
|
+
// this should be
|
120
|
+
// if (mixin in Object) return;
|
121
|
+
// but for some reason I went for JSLint ...
|
122
|
+
if (Object[mixin]) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
// same descriptor as other spec'd methods
|
126
|
+
defineProperty(
|
127
|
+
Object,
|
128
|
+
mixin,
|
129
|
+
{
|
130
|
+
enumerable: false,
|
131
|
+
writable: true,
|
132
|
+
configurable: true,
|
133
|
+
value: function (
|
134
|
+
target, // object to enrich with
|
135
|
+
source, // mixin object or Trait (Function)
|
136
|
+
args // optional arguments for Trait
|
137
|
+
) {
|
138
|
+
var
|
139
|
+
i,
|
140
|
+
length,
|
141
|
+
keys,
|
142
|
+
key;
|
143
|
+
|
144
|
+
if (typeof source === 'function') {
|
145
|
+
// if the source is a function
|
146
|
+
// it will be invoked with object as target
|
147
|
+
// this let us define mixin as closures
|
148
|
+
// function addFunctionality() {
|
149
|
+
// this.functionality = function () {
|
150
|
+
// // do amazing stuff
|
151
|
+
// }
|
152
|
+
// }
|
153
|
+
// addFunctionality.call(Class.prototype);
|
154
|
+
// addFunctionality.call(genericObject);
|
155
|
+
// // or
|
156
|
+
// Object.mixin(Class.prototype, addFunctionality);
|
157
|
+
|
158
|
+
source.apply(target, args || emptyArray);
|
159
|
+
/*
|
160
|
+
// try to perform as fast as possible
|
161
|
+
if (arguments.length < 3) {
|
162
|
+
// so if no extra args are passed ...
|
163
|
+
source.call(target);
|
164
|
+
} else {
|
165
|
+
// there is no need to slice them as done here
|
166
|
+
source.apply(target, slice.call(arguments, 2));
|
167
|
+
}
|
168
|
+
*/
|
169
|
+
} else {
|
170
|
+
// if source is an object
|
171
|
+
// grab all possibe properties
|
172
|
+
// and per each of them ...
|
173
|
+
keys = getOwnPropertyNames(source);
|
174
|
+
length = keys.length;
|
175
|
+
i = 0;
|
176
|
+
while (i < length) {
|
177
|
+
key = keys[i++];
|
178
|
+
// ... define it ...
|
179
|
+
defineProperty(
|
180
|
+
target,
|
181
|
+
key,
|
182
|
+
// ... using the same descriptor
|
183
|
+
getOwnPropertyDescriptor(
|
184
|
+
source,
|
185
|
+
key
|
186
|
+
)
|
187
|
+
);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
// always return the initial target
|
191
|
+
// ignoring all possible different return with functions
|
192
|
+
return target;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
);
|
196
|
+
}(Object, 'mixin'));
|
@@ -0,0 +1,199 @@
|
|
1
|
+
/**
|
2
|
+
* @depend ../sinon.js
|
3
|
+
* @depend stub.js
|
4
|
+
*/
|
5
|
+
/*jslint eqeqeq: false, onevar: false, nomen: false, plusplus: false*/
|
6
|
+
/*global module, require, sinon*/
|
7
|
+
/**
|
8
|
+
* Assertions matching the test spy retrieval interface.
|
9
|
+
*
|
10
|
+
* @author Christian Johansen (christian@cjohansen.no)
|
11
|
+
* @license BSD
|
12
|
+
*
|
13
|
+
* Copyright (c) 2010-2013 Christian Johansen
|
14
|
+
*/
|
15
|
+
"use strict";
|
16
|
+
|
17
|
+
(function (sinon, global) {
|
18
|
+
var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function";
|
19
|
+
var slice = Array.prototype.slice;
|
20
|
+
var assert;
|
21
|
+
|
22
|
+
if (!sinon && commonJSModule) {
|
23
|
+
sinon = require("../sinon");
|
24
|
+
}
|
25
|
+
|
26
|
+
if (!sinon) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
function verifyIsStub() {
|
31
|
+
var method;
|
32
|
+
|
33
|
+
for (var i = 0, l = arguments.length; i < l; ++i) {
|
34
|
+
method = arguments[i];
|
35
|
+
|
36
|
+
if (!method) {
|
37
|
+
assert.fail("fake is not a spy");
|
38
|
+
}
|
39
|
+
|
40
|
+
if (typeof method != "function") {
|
41
|
+
assert.fail(method + " is not a function");
|
42
|
+
}
|
43
|
+
|
44
|
+
if (typeof method.getCall != "function") {
|
45
|
+
assert.fail(method + " is not stubbed");
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
function failAssertion(object, msg) {
|
51
|
+
object = object || global;
|
52
|
+
var failMethod = object.fail || assert.fail;
|
53
|
+
failMethod.call(object, msg);
|
54
|
+
}
|
55
|
+
|
56
|
+
function mirrorPropAsAssertion(name, method, message) {
|
57
|
+
if (arguments.length == 2) {
|
58
|
+
message = method;
|
59
|
+
method = name;
|
60
|
+
}
|
61
|
+
|
62
|
+
assert[name] = function (fake) {
|
63
|
+
verifyIsStub(fake);
|
64
|
+
|
65
|
+
var args = slice.call(arguments, 1);
|
66
|
+
var failed = false;
|
67
|
+
|
68
|
+
if (typeof method == "function") {
|
69
|
+
failed = !method(fake);
|
70
|
+
} else {
|
71
|
+
failed = typeof fake[method] == "function" ?
|
72
|
+
!fake[method].apply(fake, args) : !fake[method];
|
73
|
+
}
|
74
|
+
|
75
|
+
if (failed) {
|
76
|
+
failAssertion(this, fake.printf.apply(fake, [message].concat(args)));
|
77
|
+
} else {
|
78
|
+
assert.pass(name);
|
79
|
+
}
|
80
|
+
};
|
81
|
+
}
|
82
|
+
|
83
|
+
function exposedName(prefix, prop) {
|
84
|
+
return !prefix || /^fail/.test(prop) ? prop :
|
85
|
+
prefix + prop.slice(0, 1).toUpperCase() + prop.slice(1);
|
86
|
+
}
|
87
|
+
|
88
|
+
assert = {
|
89
|
+
failException: "AssertError",
|
90
|
+
|
91
|
+
fail: function fail(message) {
|
92
|
+
var error = new Error(message);
|
93
|
+
error.name = this.failException || assert.failException;
|
94
|
+
|
95
|
+
throw error;
|
96
|
+
},
|
97
|
+
|
98
|
+
pass: function pass(assertion) {},
|
99
|
+
|
100
|
+
callOrder: function assertCallOrder() {
|
101
|
+
verifyIsStub.apply(null, arguments);
|
102
|
+
var expected = "", actual = "";
|
103
|
+
|
104
|
+
if (!sinon.calledInOrder(arguments)) {
|
105
|
+
try {
|
106
|
+
expected = [].join.call(arguments, ", ");
|
107
|
+
var calls = slice.call(arguments);
|
108
|
+
var i = calls.length;
|
109
|
+
while (i) {
|
110
|
+
if (!calls[--i].called) {
|
111
|
+
calls.splice(i, 1);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
actual = sinon.orderByFirstCall(calls).join(", ");
|
115
|
+
} catch (e) {
|
116
|
+
// If this fails, we'll just fall back to the blank string
|
117
|
+
}
|
118
|
+
|
119
|
+
failAssertion(this, "expected " + expected + " to be " +
|
120
|
+
"called in order but were called as " + actual);
|
121
|
+
} else {
|
122
|
+
assert.pass("callOrder");
|
123
|
+
}
|
124
|
+
},
|
125
|
+
|
126
|
+
callCount: function assertCallCount(method, count) {
|
127
|
+
verifyIsStub(method);
|
128
|
+
|
129
|
+
if (method.callCount != count) {
|
130
|
+
var msg = "expected %n to be called " + sinon.timesInWords(count) +
|
131
|
+
" but was called %c%C";
|
132
|
+
failAssertion(this, method.printf(msg));
|
133
|
+
} else {
|
134
|
+
assert.pass("callCount");
|
135
|
+
}
|
136
|
+
},
|
137
|
+
|
138
|
+
expose: function expose(target, options) {
|
139
|
+
if (!target) {
|
140
|
+
throw new TypeError("target is null or undefined");
|
141
|
+
}
|
142
|
+
|
143
|
+
var o = options || {};
|
144
|
+
var prefix = typeof o.prefix == "undefined" && "assert" || o.prefix;
|
145
|
+
var includeFail = typeof o.includeFail == "undefined" || !!o.includeFail;
|
146
|
+
|
147
|
+
for (var method in this) {
|
148
|
+
if (method != "export" && (includeFail || !/^(fail)/.test(method))) {
|
149
|
+
target[exposedName(prefix, method)] = this[method];
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
return target;
|
154
|
+
},
|
155
|
+
|
156
|
+
match: function match(actual, expectation) {
|
157
|
+
var matcher = sinon.match(expectation);
|
158
|
+
if (matcher.test(actual)) {
|
159
|
+
assert.pass("match");
|
160
|
+
} else {
|
161
|
+
var formatted = [
|
162
|
+
"expected value to match",
|
163
|
+
" expected = " + sinon.format(expectation),
|
164
|
+
" actual = " + sinon.format(actual)
|
165
|
+
]
|
166
|
+
failAssertion(this, formatted.join("\n"));
|
167
|
+
}
|
168
|
+
}
|
169
|
+
};
|
170
|
+
|
171
|
+
mirrorPropAsAssertion("called", "expected %n to have been called at least once but was never called");
|
172
|
+
mirrorPropAsAssertion("notCalled", function (spy) { return !spy.called; },
|
173
|
+
"expected %n to not have been called but was called %c%C");
|
174
|
+
mirrorPropAsAssertion("calledOnce", "expected %n to be called once but was called %c%C");
|
175
|
+
mirrorPropAsAssertion("calledTwice", "expected %n to be called twice but was called %c%C");
|
176
|
+
mirrorPropAsAssertion("calledThrice", "expected %n to be called thrice but was called %c%C");
|
177
|
+
mirrorPropAsAssertion("calledOn", "expected %n to be called with %1 as this but was called with %t");
|
178
|
+
mirrorPropAsAssertion("alwaysCalledOn", "expected %n to always be called with %1 as this but was called with %t");
|
179
|
+
mirrorPropAsAssertion("calledWithNew", "expected %n to be called with new");
|
180
|
+
mirrorPropAsAssertion("alwaysCalledWithNew", "expected %n to always be called with new");
|
181
|
+
mirrorPropAsAssertion("calledWith", "expected %n to be called with arguments %*%C");
|
182
|
+
mirrorPropAsAssertion("calledWithMatch", "expected %n to be called with match %*%C");
|
183
|
+
mirrorPropAsAssertion("alwaysCalledWith", "expected %n to always be called with arguments %*%C");
|
184
|
+
mirrorPropAsAssertion("alwaysCalledWithMatch", "expected %n to always be called with match %*%C");
|
185
|
+
mirrorPropAsAssertion("calledWithExactly", "expected %n to be called with exact arguments %*%C");
|
186
|
+
mirrorPropAsAssertion("alwaysCalledWithExactly", "expected %n to always be called with exact arguments %*%C");
|
187
|
+
mirrorPropAsAssertion("neverCalledWith", "expected %n to never be called with arguments %*%C");
|
188
|
+
mirrorPropAsAssertion("neverCalledWithMatch", "expected %n to never be called with match %*%C");
|
189
|
+
mirrorPropAsAssertion("threw", "%n did not throw exception%C");
|
190
|
+
mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C");
|
191
|
+
|
192
|
+
sinon.assert = assert;
|
193
|
+
|
194
|
+
if (typeof define === "function" && define.amd) {
|
195
|
+
define(["module"], function(module) { module.exports = assert; });
|
196
|
+
} else if (commonJSModule) {
|
197
|
+
module.exports = assert;
|
198
|
+
}
|
199
|
+
}(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : (typeof self != "undefined") ? self : global));
|