ende 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/component.json +2 -2
- data/components/indefinido/indemma/master/component.json +27 -17
- data/components/indefinido/indemma/master/lib/record/associable.js +74 -75
- data/components/indefinido/indemma/master/lib/record/dirtyable.js +40 -0
- data/components/indefinido/indemma/master/lib/record/queryable.js +2 -2
- data/components/indefinido/indemma/master/lib/record/resource.js +1 -1
- data/components/indefinido/indemma/master/lib/record/rest.js +7 -2
- data/components/indefinido/indemma/master/lib/record/restfulable.js +37 -10
- data/components/indefinido/indemma/master/lib/record/scopable.js +20 -47
- data/components/indefinido/indemma/master/lib/record/storable.js +11 -0
- data/components/indefinido/indemma/master/lib/record/validatable.js +195 -1068
- data/components/indefinido/indemma/master/lib/record.js +1 -1
- data/components/indefinido/indemma/master/vendor/stampit.js +568 -242
- data/components/indefinido/observable/es6-modules/component.json +39 -0
- data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/lib/adapters/rivets.js +3 -1
- data/components/indefinido/observable/es6-modules/lib/legacy/notifierable.js +145 -0
- data/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +114 -0
- data/components/indefinido/observable/es6-modules/lib/lookup.js +38 -0
- data/components/indefinido/observable/es6-modules/lib/observable/keypath_observer.js +38 -0
- data/components/indefinido/observable/es6-modules/lib/observable/observation.js +45 -0
- data/components/indefinido/observable/es6-modules/lib/observable/selection.js +57 -0
- data/components/indefinido/observable/es6-modules/lib/observable/self_observer.js +38 -0
- data/components/indefinido/observable/es6-modules/lib/observable.js +90 -0
- data/components/indefinido/observable/es6-modules/lib/platform.js +12 -0
- data/components/indefinido/observable/es6-modules/vendor/observe-js/observe.js +1631 -0
- data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/accessors.js +85 -10
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +1 -1
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.js +18379 -26828
- metadata +20 -128
- data/components/indefinido/indemma/master/.gitignore +0 -17
- data/components/indefinido/indemma/master/.ruby-gemset +0 -1
- data/components/indefinido/indemma/master/.ruby-version +0 -1
- data/components/indefinido/indemma/master/Gemfile +0 -13
- data/components/indefinido/indemma/master/Guardfile +0 -39
- data/components/indefinido/indemma/master/History.md +0 -0
- data/components/indefinido/indemma/master/Readme.md +0 -447
- data/components/indefinido/indemma/master/build/build.js +0 -26288
- data/components/indefinido/indemma/master/build/development.js +0 -22200
- data/components/indefinido/indemma/master/build/release.js +0 -22139
- data/components/indefinido/indemma/master/build/test.js +0 -22200
- data/components/indefinido/indemma/master/components/chaijs-assertion-error/component.json +0 -18
- data/components/indefinido/indemma/master/components/chaijs-assertion-error/index.js +0 -110
- data/components/indefinido/indemma/master/components/chaijs-chai/component.json +0 -47
- data/components/indefinido/indemma/master/components/chaijs-chai/index.js +0 -1
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/assertion.js +0 -130
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/core/assertions.js +0 -1270
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/interface/assert.js +0 -1080
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/interface/expect.js +0 -12
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/interface/should.js +0 -76
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +0 -94
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addMethod.js +0 -37
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addProperty.js +0 -40
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/eql.js +0 -129
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/flag.js +0 -32
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getActual.js +0 -19
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +0 -25
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getMessage.js +0 -49
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getName.js +0 -20
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getPathValue.js +0 -102
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getProperties.js +0 -35
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/index.js +0 -108
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/inspect.js +0 -320
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/objDisplay.js +0 -48
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +0 -51
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +0 -54
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/test.js +0 -26
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/transferFlags.js +0 -44
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/type.js +0 -45
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai.js +0 -80
- data/components/indefinido/indemma/master/components/component-bind/component.json +0 -14
- data/components/indefinido/indemma/master/components/component-bind/index.js +0 -24
- data/components/indefinido/indemma/master/components/component-jquery/component.json +0 -14
- data/components/indefinido/indemma/master/components/component-jquery/index.js +0 -9601
- data/components/indefinido/indemma/master/components/component-type/component.json +0 -18
- data/components/indefinido/indemma/master/components/component-type/index.js +0 -32
- data/components/indefinido/indemma/master/components/indefinido-advisable/component.json +0 -21
- data/components/indefinido/indemma/master/components/indefinido-advisable/index.js +0 -1
- data/components/indefinido/indemma/master/components/indefinido-advisable/lib/advisable.js +0 -60
- data/components/indefinido/indemma/master/components/indefinido-observable/component.json +0 -25
- data/components/indefinido/indemma/master/components/indefinido-observable/components/cjohansen-sinon/sinon.js +0 -4290
- data/components/indefinido/indemma/master/components/indefinido-observable/lib/observable.js +0 -323
- data/components/indefinido/indemma/master/components/kapit-observe-utils/component.json +0 -13
- data/components/indefinido/indemma/master/components/paulmillr-es6-shim/component.json +0 -17
- data/components/indefinido/indemma/master/components/paulmillr-es6-shim/es6-shim.js +0 -996
- data/components/indefinido/indemma/master/components/pluma-assimilate/component.json +0 -25
- data/components/indefinido/indemma/master/components/pluma-assimilate/dist/assimilate.js +0 -127
- data/components/indefinido/indemma/master/karma.conf.js +0 -76
- data/components/indefinido/indemma/master/package.json +0 -9
- data/components/indefinido/indemma/master/spec/record/associable_spec.js +0 -137
- data/components/indefinido/indemma/master/spec/record/persistable_spec.js +0 -36
- data/components/indefinido/indemma/master/spec/record/queryable_spec.js +0 -33
- data/components/indefinido/indemma/master/spec/record/resource_spec.js +0 -93
- data/components/indefinido/indemma/master/spec/record/rest_spec.js +0 -32
- data/components/indefinido/indemma/master/spec/record/restfulable_spec.js +0 -300
- data/components/indefinido/indemma/master/spec/record/scopable_spec.js +0 -212
- data/components/indefinido/indemma/master/spec/record/storable_spec.js +0 -53
- data/components/indefinido/indemma/master/spec/record/translationable.js +0 -28
- data/components/indefinido/indemma/master/spec/record/validatable_spec.js +0 -111
- data/components/indefinido/indemma/master/spec/record/validations/associated_spec.js +0 -43
- data/components/indefinido/indemma/master/spec/record/validations/confirmation_spec.js +0 -36
- data/components/indefinido/indemma/master/spec/record/validations/cpf_spec.js +0 -35
- data/components/indefinido/indemma/master/spec/record/validations/presence_spec.js +0 -28
- data/components/indefinido/indemma/master/spec/record/validations/remote_spec.js +0 -87
- data/components/indefinido/indemma/master/spec/record/validations/type_spec.js +0 -48
- data/components/indefinido/indemma/master/spec/record_spec.js +0 -37
- data/components/indefinido/indemma/master/spec/spec_helper.js +0 -11
- data/components/indefinido/indemma/master/spec/support/value_objects/phone.js +0 -45
- data/components/indefinido/indemma/master/src/lib/extensions/rivets.coffee +0 -17
- data/components/indefinido/indemma/master/src/lib/record/associable.coffee +0 -380
- data/components/indefinido/indemma/master/src/lib/record/errors.coffee +0 -20
- data/components/indefinido/indemma/master/src/lib/record/maid.coffee +0 -16
- data/components/indefinido/indemma/master/src/lib/record/persistable.coffee +0 -32
- data/components/indefinido/indemma/master/src/lib/record/queryable.coffee +0 -30
- data/components/indefinido/indemma/master/src/lib/record/resource.coffee +0 -106
- data/components/indefinido/indemma/master/src/lib/record/rest.coffee +0 -28
- data/components/indefinido/indemma/master/src/lib/record/restfulable.coffee +0 -447
- data/components/indefinido/indemma/master/src/lib/record/scopable.coffee +0 -294
- data/components/indefinido/indemma/master/src/lib/record/storable.coffee +0 -46
- data/components/indefinido/indemma/master/src/lib/record/translationable.coffee +0 -18
- data/components/indefinido/indemma/master/src/lib/record/validatable.coffee +0 -207
- data/components/indefinido/indemma/master/src/lib/record/validations/associated.coffee +0 -30
- data/components/indefinido/indemma/master/src/lib/record/validations/confirmation.coffee +0 -17
- data/components/indefinido/indemma/master/src/lib/record/validations/cpf.coffee +0 -57
- data/components/indefinido/indemma/master/src/lib/record/validations/presence.coffee +0 -16
- data/components/indefinido/indemma/master/src/lib/record/validations/remote.coffee +0 -61
- data/components/indefinido/indemma/master/src/lib/record/validations/type.coffee +0 -31
- data/components/indefinido/indemma/master/src/lib/record/validations/validatorable.coffee +0 -5
- data/components/indefinido/indemma/master/src/lib/record.coffee +0 -138
- data/components/indefinido/indemma/master/src/spec/record/associable_spec.coffee +0 -130
- data/components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee +0 -30
- data/components/indefinido/indemma/master/src/spec/record/queryable_spec.coffee +0 -27
- data/components/indefinido/indemma/master/src/spec/record/resource_spec.coffee +0 -69
- data/components/indefinido/indemma/master/src/spec/record/rest_spec.coffee +0 -22
- data/components/indefinido/indemma/master/src/spec/record/restfulable_spec.coffee +0 -215
- data/components/indefinido/indemma/master/src/spec/record/scopable_spec.coffee +0 -191
- data/components/indefinido/indemma/master/src/spec/record/storable_spec.coffee +0 -40
- data/components/indefinido/indemma/master/src/spec/record/translationable.coffee +0 -19
- data/components/indefinido/indemma/master/src/spec/record/validatable_spec.coffee +0 -100
- data/components/indefinido/indemma/master/src/spec/record/validations/associated_spec.coffee +0 -35
- data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee +0 -25
- data/components/indefinido/indemma/master/src/spec/record/validations/cpf_spec.coffee +0 -28
- data/components/indefinido/indemma/master/src/spec/record/validations/presence_spec.coffee +0 -24
- data/components/indefinido/indemma/master/src/spec/record/validations/remote_spec.coffee +0 -74
- data/components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee +0 -33
- data/components/indefinido/indemma/master/src/spec/record_spec.coffee +0 -23
- data/components/indefinido/indemma/master/src/spec/spec_helper.coffee +0 -9
- data/components/indefinido/indemma/master/src/spec/support/value_objects/phone.coffee +0 -30
- data/components/indefinido/indemma/master/vendor/object/mixin.js +0 -196
- data/components/indefinido/indemma/master/vendor/sinon.js +0 -4290
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/index.js +0 -0
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/accessors-legacy.js +0 -0
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/array.indexOf.js +0 -0
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/object.create.js +0 -0
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
var jQuery, model, record, root, should_behave_like_errorsable;
|
|
2
|
-
|
|
3
|
-
require('indemma/lib/record/restfulable');
|
|
4
|
-
|
|
5
|
-
require('indemma/lib/record/validatable');
|
|
6
|
-
|
|
7
|
-
require('indemma/lib/record/resource');
|
|
8
|
-
|
|
9
|
-
'use strict';
|
|
10
|
-
|
|
11
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
|
12
|
-
|
|
13
|
-
model = root.model;
|
|
14
|
-
|
|
15
|
-
record = root.record;
|
|
16
|
-
|
|
17
|
-
jQuery = require('component-jquery');
|
|
18
|
-
|
|
19
|
-
should_behave_like_errorsable = function() {
|
|
20
|
-
return describe('.errors', function() {
|
|
21
|
-
return describe('when server responds', function() {
|
|
22
|
-
beforeEach(function() {
|
|
23
|
-
return this.xhr = {
|
|
24
|
-
status: 422
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
describe('with errors', function() {
|
|
28
|
-
it('should add messages for each attribute on the errors object');
|
|
29
|
-
return it('should add messages for base attribute on the errors object', function() {
|
|
30
|
-
var base_messages;
|
|
31
|
-
|
|
32
|
-
base_messages = ["arthur you should bring a towel!"];
|
|
33
|
-
this.xhr.responseText = JSON.stringify({
|
|
34
|
-
errors: {
|
|
35
|
-
base: base_messages
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
this.subject.failed(this.xhr, 'error');
|
|
39
|
-
this.subject.should.have.property('errors');
|
|
40
|
-
this.subject.errors[0].should.include('base', 'server', {
|
|
41
|
-
server_message: base_messages[0]
|
|
42
|
-
});
|
|
43
|
-
return this.subject.errors.messages.should.have.property('base', base_messages[0]);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
return describe('with invalid error messages', function() {
|
|
47
|
-
return it('when inexistent attribute should throw exception', function() {});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
describe('restfulable', function() {
|
|
54
|
-
describe('when included', function() {
|
|
55
|
-
return it('sets te restufulable loaded flag on model', function() {
|
|
56
|
-
return model.restfulable.should.be["true"];
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe('record', function() {
|
|
60
|
-
var arthur;
|
|
61
|
-
|
|
62
|
-
arthur = null;
|
|
63
|
-
return describe('()', function() {
|
|
64
|
-
beforeEach(function() {
|
|
65
|
-
this.arthur = arthur = record.call({
|
|
66
|
-
resource: 'person',
|
|
67
|
-
name: 'Arthur Philip Dent'
|
|
68
|
-
});
|
|
69
|
-
return this.arthur.dirty = true;
|
|
70
|
-
});
|
|
71
|
-
return describe('.save()', function() {
|
|
72
|
-
beforeEach(function() {
|
|
73
|
-
return sinon.stub(jQuery, "ajax").returns(jQuery.Deferred());
|
|
74
|
-
});
|
|
75
|
-
afterEach(function() {
|
|
76
|
-
return jQuery.ajax.restore();
|
|
77
|
-
});
|
|
78
|
-
it('should be able to serialize record', function() {
|
|
79
|
-
return JSON.stringify(arthur.json());
|
|
80
|
-
});
|
|
81
|
-
it('should ignore key in transient fields');
|
|
82
|
-
it('should send paramenters accordingly');
|
|
83
|
-
return it('should make ajax call', function() {
|
|
84
|
-
arthur.save();
|
|
85
|
-
return jQuery.ajax.called.should.be["true"];
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
return describe('model', function() {
|
|
91
|
-
return describe('()', function() {
|
|
92
|
-
describe('.json()', function() {
|
|
93
|
-
var friend, person;
|
|
94
|
-
|
|
95
|
-
friend = person = null;
|
|
96
|
-
return beforeEach(function() {
|
|
97
|
-
person = model.call({
|
|
98
|
-
resource: 'person',
|
|
99
|
-
has_many: 'friends',
|
|
100
|
-
nested_attributes: ['friends'],
|
|
101
|
-
name: String
|
|
102
|
-
});
|
|
103
|
-
return friend = model.call({
|
|
104
|
-
resource: 'friend',
|
|
105
|
-
belongs_to: 'person'
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
describe('.assign_attributes()', function() {
|
|
110
|
-
var friend, person;
|
|
111
|
-
|
|
112
|
-
friend = person = null;
|
|
113
|
-
beforeEach(function() {
|
|
114
|
-
person = model.call({
|
|
115
|
-
resource: 'person',
|
|
116
|
-
has_many: 'friends',
|
|
117
|
-
name: String
|
|
118
|
-
});
|
|
119
|
-
return friend = model.call({
|
|
120
|
-
resource: 'friend',
|
|
121
|
-
belongs_to: 'person'
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
it('should not assign attribute with the same value twice', function() {
|
|
125
|
-
var arthur, object;
|
|
126
|
-
|
|
127
|
-
object = {};
|
|
128
|
-
arthur = person({
|
|
129
|
-
name: object
|
|
130
|
-
});
|
|
131
|
-
arthur.assign_attributes({
|
|
132
|
-
name: {}
|
|
133
|
-
});
|
|
134
|
-
return arthur.name.should.not.be.eq(object);
|
|
135
|
-
});
|
|
136
|
-
return it('assigns associations properly', function() {
|
|
137
|
-
var arthur, attributes, ford, marvin, search_record;
|
|
138
|
-
|
|
139
|
-
arthur = person({
|
|
140
|
-
name: 'Arthur Dent'
|
|
141
|
-
});
|
|
142
|
-
ford = friend({
|
|
143
|
-
name: 'Ford Perfect'
|
|
144
|
-
});
|
|
145
|
-
marvin = friend({
|
|
146
|
-
name: 'Marvin'
|
|
147
|
-
});
|
|
148
|
-
attributes = {
|
|
149
|
-
friends: [ford, marvin]
|
|
150
|
-
};
|
|
151
|
-
arthur.assign_attributes(attributes);
|
|
152
|
-
search_record = function(association, search) {
|
|
153
|
-
var associated, _i, _len;
|
|
154
|
-
|
|
155
|
-
search = JSON.stringify(search.json());
|
|
156
|
-
for (_i = 0, _len = association.length; _i < _len; _i++) {
|
|
157
|
-
associated = association[_i];
|
|
158
|
-
associated = JSON.stringify(associated.json());
|
|
159
|
-
if (associated === search) {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return false;
|
|
164
|
-
};
|
|
165
|
-
search_record(arthur.friends, ford).should.be.eq["true"];
|
|
166
|
-
return search_record(arthur.friends, arthur).should.be.eq["true"];
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
describe('with singular resource', function() {
|
|
170
|
-
return describe('.create()', function() {
|
|
171
|
-
it('should return promises');
|
|
172
|
-
return it('should return models when promise is resolved');
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
describe('with plural resource', function() {
|
|
176
|
-
return describe('.create()', function() {
|
|
177
|
-
var deferred, person, promise;
|
|
178
|
-
|
|
179
|
-
deferred = promise = person = null;
|
|
180
|
-
should_behave_like_errorsable();
|
|
181
|
-
beforeEach(function() {
|
|
182
|
-
var context;
|
|
183
|
-
|
|
184
|
-
person = model.call({
|
|
185
|
-
resource: 'person'
|
|
186
|
-
});
|
|
187
|
-
deferred = jQuery.Deferred();
|
|
188
|
-
this.subject = context = person({
|
|
189
|
-
name: 'Arthur'
|
|
190
|
-
});
|
|
191
|
-
context.lock = JSON.stringify(context.json());
|
|
192
|
-
deferred.resolveWith(context, [
|
|
193
|
-
{
|
|
194
|
-
_id: 1,
|
|
195
|
-
name: 'Arthur'
|
|
196
|
-
}
|
|
197
|
-
]);
|
|
198
|
-
deferred.resolveWith(person({
|
|
199
|
-
name: 'Arthur'
|
|
200
|
-
}), [
|
|
201
|
-
{
|
|
202
|
-
_id: 1,
|
|
203
|
-
name: 'Arthur'
|
|
204
|
-
}
|
|
205
|
-
]);
|
|
206
|
-
sinon.stub(jQuery, "ajax").returns(deferred);
|
|
207
|
-
return promise = person.create({
|
|
208
|
-
name: 'Arthur'
|
|
209
|
-
}, {
|
|
210
|
-
name: 'Ford'
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
afterEach(function() {
|
|
214
|
-
return jQuery.ajax.restore();
|
|
215
|
-
});
|
|
216
|
-
it('should return a promise', function(done) {
|
|
217
|
-
promise.done.should.be["function"];
|
|
218
|
-
promise.state().should.be.eq('resolved');
|
|
219
|
-
return promise.done(function() {
|
|
220
|
-
return done();
|
|
221
|
-
}).should.be.eq('resolved');
|
|
222
|
-
});
|
|
223
|
-
it('should return models when promise is resolved', function(done) {
|
|
224
|
-
var created;
|
|
225
|
-
|
|
226
|
-
created = function() {
|
|
227
|
-
this.name.should.be.eq('Arthur');
|
|
228
|
-
return done();
|
|
229
|
-
};
|
|
230
|
-
return person.create({
|
|
231
|
-
name: 'Arthur'
|
|
232
|
-
}, {
|
|
233
|
-
name: 'Ford'
|
|
234
|
-
}, created);
|
|
235
|
-
});
|
|
236
|
-
it('should optionally accept create callback', function(done) {
|
|
237
|
-
promise = person.create({
|
|
238
|
-
name: 'Arthur'
|
|
239
|
-
}, {
|
|
240
|
-
name: 'Ford'
|
|
241
|
-
});
|
|
242
|
-
promise.done.should.be["function"];
|
|
243
|
-
promise.done(function() {
|
|
244
|
-
return done();
|
|
245
|
-
});
|
|
246
|
-
return promise.state().should.be.eq('resolved');
|
|
247
|
-
});
|
|
248
|
-
it('should create record when only callback is passed', function(done) {
|
|
249
|
-
person.create(function() {
|
|
250
|
-
return done();
|
|
251
|
-
});
|
|
252
|
-
return jQuery.ajax.callCount.should.be.eq(3);
|
|
253
|
-
});
|
|
254
|
-
it('should throw exception when nothing is passed', function() {
|
|
255
|
-
return expect(person.create).to["throw"](TypeError);
|
|
256
|
-
});
|
|
257
|
-
return it('should make ajax calls', function() {
|
|
258
|
-
return jQuery.ajax.callCount.should.be.eq(3);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
return describe('.destroy()', function() {
|
|
263
|
-
return describe('with plural resource', function() {
|
|
264
|
-
var arthur, deferred, person;
|
|
265
|
-
|
|
266
|
-
arthur = person = deferred = null;
|
|
267
|
-
beforeEach(function() {
|
|
268
|
-
person = model.call({
|
|
269
|
-
resource: 'person'
|
|
270
|
-
});
|
|
271
|
-
deferred = jQuery.Deferred();
|
|
272
|
-
deferred.resolveWith(person({
|
|
273
|
-
name: 'Arthur'
|
|
274
|
-
}), [
|
|
275
|
-
{
|
|
276
|
-
id: 1
|
|
277
|
-
}
|
|
278
|
-
]);
|
|
279
|
-
sinon.stub(jQuery, "ajax").returns(deferred);
|
|
280
|
-
return arthur = person({
|
|
281
|
-
name: 'Arthur',
|
|
282
|
-
id: 1
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
afterEach(function() {
|
|
286
|
-
return jQuery.ajax.restore();
|
|
287
|
-
});
|
|
288
|
-
it("throw exception when record has no id", function() {
|
|
289
|
-
delete arthur.id;
|
|
290
|
-
return expect(arthur.destroy).to["throw"](Error);
|
|
291
|
-
});
|
|
292
|
-
return it("should make ajax calls", function() {
|
|
293
|
-
arthur.destroy();
|
|
294
|
-
return jQuery.ajax.callCount.should.be.eq(1);
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
var model, record, root;
|
|
2
|
-
|
|
3
|
-
require('indemma/lib/record/resource');
|
|
4
|
-
|
|
5
|
-
require('indemma/lib/record/restfulable');
|
|
6
|
-
|
|
7
|
-
require('indemma/lib/record/scopable');
|
|
8
|
-
|
|
9
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
|
10
|
-
|
|
11
|
-
model = root.model;
|
|
12
|
-
|
|
13
|
-
record = root.record;
|
|
14
|
-
|
|
15
|
-
describe('scopable', function() {
|
|
16
|
-
describe('when included', function() {
|
|
17
|
-
return it('sets te scopable loaded flag on model', function() {
|
|
18
|
-
return model.scopable.should.be["true"];
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
return describe('model', function() {
|
|
22
|
-
return describe('#(options)', function() {
|
|
23
|
-
var person;
|
|
24
|
-
|
|
25
|
-
person = null;
|
|
26
|
-
beforeEach(function() {
|
|
27
|
-
return person = model.call({
|
|
28
|
-
$hetero: true,
|
|
29
|
-
$by_type: [],
|
|
30
|
-
$by_name: String,
|
|
31
|
-
resource: 'person'
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it('should add scope methods to model', function() {
|
|
35
|
-
return person.none.should.be["function"];
|
|
36
|
-
});
|
|
37
|
-
it('should generate scope methods based on model definition', function() {
|
|
38
|
-
return person.hetero.should.be["function"];
|
|
39
|
-
});
|
|
40
|
-
describe('#none', function() {
|
|
41
|
-
return it('should return empty response on fetch calls', function(done) {
|
|
42
|
-
return person.none().fetch(null, function(people) {
|
|
43
|
-
people.length.should.be.empty;
|
|
44
|
-
return done();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe('scope', function() {
|
|
49
|
-
return describe('#(name, type)', function() {
|
|
50
|
-
return it('should add scope methods to model', function() {
|
|
51
|
-
person.scope('bissexual', Boolean);
|
|
52
|
-
return person.bissexual.should.be["function"];
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
return describe('#{generated_scope}', function() {
|
|
57
|
-
var deferred;
|
|
58
|
-
|
|
59
|
-
deferred = null;
|
|
60
|
-
beforeEach(function() {
|
|
61
|
-
deferred = jQuery.Deferred();
|
|
62
|
-
sinon.stub(jQuery, "ajax").returns(deferred);
|
|
63
|
-
return person.scope.clear();
|
|
64
|
-
});
|
|
65
|
-
afterEach(function() {
|
|
66
|
-
return jQuery.ajax.restore();
|
|
67
|
-
});
|
|
68
|
-
describe('#all', function() {
|
|
69
|
-
var promises;
|
|
70
|
-
|
|
71
|
-
deferred = promises = person = null;
|
|
72
|
-
return it('should return models when promise is resolved', function(done) {
|
|
73
|
-
var fetched;
|
|
74
|
-
|
|
75
|
-
fetched = function(people) {
|
|
76
|
-
people.should.be.array;
|
|
77
|
-
people[0].name.should.be.string;
|
|
78
|
-
return done();
|
|
79
|
-
};
|
|
80
|
-
person.every(fetched);
|
|
81
|
-
deferred.resolveWith(person, [
|
|
82
|
-
[
|
|
83
|
-
{
|
|
84
|
-
name: 'Arthur'
|
|
85
|
-
}, {
|
|
86
|
-
name: 'Ford'
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
]);
|
|
90
|
-
return jQuery.ajax.callCount.should.be.eq(1);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
describe('when string', function() {
|
|
94
|
-
it('should acumulate data in scope object', function() {
|
|
95
|
-
person.by_name();
|
|
96
|
-
return person.scope.data.by_name.should.be.a('string');
|
|
97
|
-
});
|
|
98
|
-
return it('should override data throught parameters', function() {
|
|
99
|
-
person.by_name('Ford');
|
|
100
|
-
return person.scope.data.by_name.should.be.eq('Ford');
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
describe('when array', function() {
|
|
104
|
-
it('should acumulate data in scope object', function() {
|
|
105
|
-
person.by_type();
|
|
106
|
-
return person.scope.data.by_type.should.be.a('array');
|
|
107
|
-
});
|
|
108
|
-
it('should override data throught parameters', function() {
|
|
109
|
-
person.by_type(1, 2, 3);
|
|
110
|
-
return person.scope.data.by_type.should.contain(1, 2, 3);
|
|
111
|
-
});
|
|
112
|
-
it('should use default value');
|
|
113
|
-
it('should allow scope chaining');
|
|
114
|
-
return describe('xhr request', function() {
|
|
115
|
-
it('should build correct url', function() {
|
|
116
|
-
var settings;
|
|
117
|
-
|
|
118
|
-
person.by_type(1, 3, 4).fetch();
|
|
119
|
-
settings = jQuery.ajax.firstCall.args[0];
|
|
120
|
-
settings.should.have.property('data');
|
|
121
|
-
settings.data.should.have.property('by_type');
|
|
122
|
-
return settings.data.by_type.should.include(1, 3, 4);
|
|
123
|
-
});
|
|
124
|
-
return it('should make call', function() {
|
|
125
|
-
person.by_type(1, 3, 4).fetch();
|
|
126
|
-
return jQuery.ajax.callCount.should.be.eq(1);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
describe('when boolean', function() {
|
|
131
|
-
it('should acumulate data in scope object', function() {
|
|
132
|
-
person.hetero();
|
|
133
|
-
return person.scope.data.hetero.should.be.eq(true);
|
|
134
|
-
});
|
|
135
|
-
it('should override data throught parameters', function() {
|
|
136
|
-
person.hetero(false);
|
|
137
|
-
return person.scope.data.hetero.should.be.eq(false);
|
|
138
|
-
});
|
|
139
|
-
it('should allow scope chaining');
|
|
140
|
-
return it('should make ajax call', function() {
|
|
141
|
-
person.hetero().fetch();
|
|
142
|
-
return jQuery.ajax.callCount.should.be.eq(1);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
return describe('#{generated_association}', function() {
|
|
146
|
-
describe('of type belongs_to', function() {
|
|
147
|
-
var towel;
|
|
148
|
-
|
|
149
|
-
towel = null;
|
|
150
|
-
beforeEach(function() {
|
|
151
|
-
person = model.call({
|
|
152
|
-
$hetero: true,
|
|
153
|
-
$by_type: [],
|
|
154
|
-
resource: 'person'
|
|
155
|
-
});
|
|
156
|
-
return towel = model.call({
|
|
157
|
-
resource: 'towel',
|
|
158
|
-
material: 'cotton',
|
|
159
|
-
belongs_to: 'person'
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
return describe('#{generated_scope}', function() {
|
|
163
|
-
return it('can be called on association', function() {
|
|
164
|
-
var soft_towel;
|
|
165
|
-
|
|
166
|
-
soft_towel = towel({
|
|
167
|
-
material: 'silicon microfiber'
|
|
168
|
-
});
|
|
169
|
-
soft_towel.build_person();
|
|
170
|
-
return expect(soft_towel.person).to.respondTo('hetero');
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
return describe('of type has_many', function() {
|
|
175
|
-
var arthur, towel;
|
|
176
|
-
|
|
177
|
-
arthur = towel = null;
|
|
178
|
-
beforeEach(function() {
|
|
179
|
-
person = model.call({
|
|
180
|
-
$hetero: true,
|
|
181
|
-
$by_type: [],
|
|
182
|
-
resource: 'person',
|
|
183
|
-
has_many: 'towels'
|
|
184
|
-
});
|
|
185
|
-
towel = model.call({
|
|
186
|
-
$by_material: [],
|
|
187
|
-
resource: 'towel',
|
|
188
|
-
material: 'cotton',
|
|
189
|
-
belongs_to: 'person'
|
|
190
|
-
});
|
|
191
|
-
return arthur = person({
|
|
192
|
-
name: 'Arthur'
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
return describe('#{generated_scope}', function() {
|
|
196
|
-
it('can be called on association', function() {
|
|
197
|
-
return expect(arthur.towels).to.respondTo('by_material');
|
|
198
|
-
});
|
|
199
|
-
return it('should be serializable into paramenters', function() {
|
|
200
|
-
var query_string;
|
|
201
|
-
|
|
202
|
-
arthur.towels.by_material('cotton', 'microfiber');
|
|
203
|
-
query_string = decodeURIComponent(jQuery.param(arthur.towels.scope.data));
|
|
204
|
-
return query_string.should.be.eq('by_material[]=cotton&by_material[]=microfiber');
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var root, storable;
|
|
2
|
-
|
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
|
4
|
-
|
|
5
|
-
storable = require('indemma/lib/record/storable');
|
|
6
|
-
|
|
7
|
-
describe('storable', function() {
|
|
8
|
-
it('should set the storable key', function() {
|
|
9
|
-
return model.should.have.property('storable', true);
|
|
10
|
-
});
|
|
11
|
-
beforeEach(function() {
|
|
12
|
-
return this.storage = storable();
|
|
13
|
-
});
|
|
14
|
-
return describe("#store", function() {
|
|
15
|
-
describe("write", function() {
|
|
16
|
-
it("should write object on deep storage");
|
|
17
|
-
it("should write object on storage", function() {
|
|
18
|
-
var data;
|
|
19
|
-
|
|
20
|
-
data = {
|
|
21
|
-
name: 'Arthur Dent'
|
|
22
|
-
};
|
|
23
|
-
this.storage.store('1', data);
|
|
24
|
-
this.storage.writes.should.be.eq(1);
|
|
25
|
-
return this.storage.database['1'].should.be.eq(data);
|
|
26
|
-
});
|
|
27
|
-
return it("should mark an object as sustained", function() {
|
|
28
|
-
var data;
|
|
29
|
-
|
|
30
|
-
data = {
|
|
31
|
-
name: 'Arthur Dent'
|
|
32
|
-
};
|
|
33
|
-
this.storage.store('1', data);
|
|
34
|
-
return data.should.have.property('sustained', true);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
return describe("read", function() {
|
|
38
|
-
var data;
|
|
39
|
-
|
|
40
|
-
data = null;
|
|
41
|
-
beforeEach(function() {
|
|
42
|
-
data = {
|
|
43
|
-
name: 'Arthur Dent'
|
|
44
|
-
};
|
|
45
|
-
return this.storage.store('1', data);
|
|
46
|
-
});
|
|
47
|
-
it("should save object on storage", function() {
|
|
48
|
-
return this.storage.store('1').should.be.eq(data);
|
|
49
|
-
});
|
|
50
|
-
return it("should unmark an object as sustained");
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var root;
|
|
2
|
-
|
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
|
4
|
-
|
|
5
|
-
require('indemma/lib/record/translationable');
|
|
6
|
-
|
|
7
|
-
describe('model', function() {
|
|
8
|
-
var model, person;
|
|
9
|
-
|
|
10
|
-
model = root.model;
|
|
11
|
-
person = null;
|
|
12
|
-
beforeEach(function() {
|
|
13
|
-
return person = model.call({
|
|
14
|
-
resource: 'person',
|
|
15
|
-
name: String,
|
|
16
|
-
translation: {
|
|
17
|
-
attributes: {
|
|
18
|
-
name: 'Batata'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
return describe('#human_attribute_name', function() {
|
|
24
|
-
return it('should return the translated attribute name', function() {
|
|
25
|
-
return person.human_attribute_name('name').should.be.eq('Batata');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
var root;
|
|
2
|
-
|
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
|
4
|
-
|
|
5
|
-
require('indemma/lib/record/validatable');
|
|
6
|
-
|
|
7
|
-
describe('model', function() {
|
|
8
|
-
var corporation, model, person;
|
|
9
|
-
|
|
10
|
-
model = root.model;
|
|
11
|
-
person = corporation = null;
|
|
12
|
-
beforeEach(function() {
|
|
13
|
-
return person = model.call({
|
|
14
|
-
resource: 'person'
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
it('should store validators', function() {
|
|
18
|
-
person.should.have.property('validators');
|
|
19
|
-
return person.validators.should.be.an('array');
|
|
20
|
-
});
|
|
21
|
-
return describe('(validates_... : ...)', function() {
|
|
22
|
-
describe('validators instatiation', function() {
|
|
23
|
-
it('should have validators', function() {
|
|
24
|
-
var validator;
|
|
25
|
-
|
|
26
|
-
person = model.call({
|
|
27
|
-
resource: 'person',
|
|
28
|
-
name: String,
|
|
29
|
-
validates_presence_of: 'name'
|
|
30
|
-
});
|
|
31
|
-
person.validators.should.not.be.empty;
|
|
32
|
-
validator = person.validators[0];
|
|
33
|
-
return validator.should.have.property('attribute_name', 'name');
|
|
34
|
-
});
|
|
35
|
-
return it('should have validators with in the key validates');
|
|
36
|
-
});
|
|
37
|
-
describe('.validate_attribute()', function() {
|
|
38
|
-
beforeEach(function() {
|
|
39
|
-
person.validators.length = 0;
|
|
40
|
-
return person = model.call({
|
|
41
|
-
resource: 'person',
|
|
42
|
-
name: String,
|
|
43
|
-
validates_presence_of: 'name'
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
return it('should add error messages for the validated attribute', function() {
|
|
47
|
-
var arthur;
|
|
48
|
-
|
|
49
|
-
arthur = person({
|
|
50
|
-
name: null
|
|
51
|
-
});
|
|
52
|
-
arthur.validate_attribute('name');
|
|
53
|
-
arthur.errors.length.should.be.eq(1);
|
|
54
|
-
return arthur.errors.messages.should.have.property('name');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
return describe('.valid', function() {
|
|
58
|
-
person = null;
|
|
59
|
-
beforeEach(function() {
|
|
60
|
-
person.validators.length = 0;
|
|
61
|
-
return person = model.call({
|
|
62
|
-
resource: 'person',
|
|
63
|
-
name: String,
|
|
64
|
-
validates_presence_of: 'name'
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it('should be true when valid', function() {
|
|
68
|
-
var arthur;
|
|
69
|
-
|
|
70
|
-
arthur = person({
|
|
71
|
-
name: "Arthur"
|
|
72
|
-
});
|
|
73
|
-
arthur.should.have.property('valid');
|
|
74
|
-
arthur.valid.should.be["true"];
|
|
75
|
-
return arthur.errors.length.should.be.eq(0);
|
|
76
|
-
});
|
|
77
|
-
it('should exist as read only property', function() {
|
|
78
|
-
var arthur;
|
|
79
|
-
|
|
80
|
-
arthur = person({
|
|
81
|
-
name: "Arthur"
|
|
82
|
-
});
|
|
83
|
-
return expect(function() {
|
|
84
|
-
return arthur.valid = false;
|
|
85
|
-
}).to["throw"](Error);
|
|
86
|
-
});
|
|
87
|
-
it('should validate record', function() {
|
|
88
|
-
var anonymous;
|
|
89
|
-
|
|
90
|
-
anonymous = person({
|
|
91
|
-
name: null
|
|
92
|
-
});
|
|
93
|
-
anonymous.valid.should.be["false"];
|
|
94
|
-
return anonymous.errors.length.should.be.eq(1);
|
|
95
|
-
});
|
|
96
|
-
return it('should not validate record util it changes', function() {
|
|
97
|
-
var anonymous, validation;
|
|
98
|
-
|
|
99
|
-
anonymous = person({
|
|
100
|
-
name: null
|
|
101
|
-
});
|
|
102
|
-
anonymous.valid.should.be["false"];
|
|
103
|
-
anonymous.errors.length.should.be.eq(1);
|
|
104
|
-
validation = anonymous.validation;
|
|
105
|
-
anonymous.validate().should.be.eq(validation);
|
|
106
|
-
anonymous.dirty = true;
|
|
107
|
-
return anonymous.validate().should.not.be.eq(validation);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|