ende 0.4.18 → 0.4.19

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.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +1 -0
  3. data/lib/assets/javascripts/aura/extensions/widget/napable.js.coffee +2 -2
  4. data/lib/assets/javascripts/widgets/viewer/main.js.coffee +5 -6
  5. data/lib/ende/version.rb +1 -1
  6. data/vendor/assets/components/ende_build.js +40 -7
  7. data/vendor/components/indefinido-indemma/build/development.js +3 -3
  8. data/vendor/components/indefinido-indemma/build/release.js +40 -7
  9. data/vendor/components/indefinido-indemma/build/test.js +21916 -115
  10. data/vendor/components/indefinido-indemma/component.json +1 -1
  11. data/vendor/components/indefinido-indemma/lib/record/associable.js +14 -2
  12. data/vendor/components/indefinido-indemma/lib/record/restfulable.js +11 -1
  13. data/vendor/components/indefinido-indemma/lib/record/scopable.js +15 -4
  14. data/vendor/components/indefinido-indemma/spec/record/associable_spec.js +3 -2
  15. data/vendor/components/indefinido-indemma/spec/record/scopable_spec.js +83 -53
  16. data/vendor/components/indefinido-indemma/spec/record/validations/cpf_spec.js +5 -6
  17. data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +6 -0
  18. data/vendor/components/indefinido-indemma/src/lib/record/queryable.coffee +1 -2
  19. data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +14 -1
  20. data/vendor/components/indefinido-indemma/src/lib/record/scopable.coffee +18 -8
  21. data/vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee +3 -2
  22. data/vendor/components/indefinido-indemma/src/spec/record/scopable_spec.coffee +76 -43
  23. data/vendor/components/indefinido-indemma/src/spec/record/validations/cpf_spec.coffee +3 -4
  24. metadata +2 -2
@@ -20,26 +20,25 @@ describe 'scopable', ->
20
20
  describe 'model', ->
21
21
 
22
22
  describe '#(options)', ->
23
- person = null
24
23
 
25
24
  beforeEach ->
26
25
 
27
- person = model.call
26
+ @person = model.call
28
27
  $hetero : true
29
28
  $by_type: []
30
29
  $by_name: String
31
30
  resource: 'person'
32
31
 
33
32
  it 'should add scope methods to model', ->
34
- person.none.should.be.function
33
+ @person.none.should.be.function
35
34
 
36
35
  it 'should generate scope methods based on model definition', ->
37
- person.hetero.should.be.function
36
+ @person.hetero.should.be.function
38
37
 
39
38
  describe '#none', ->
40
39
  it 'should return empty response on fetch calls', (done) ->
41
40
  # TODO implement getter for none property!
42
- person.none().fetch null, (people) ->
41
+ @person.none().fetch null, (people) ->
43
42
  people.length.should.be.empty
44
43
  done()
45
44
 
@@ -49,23 +48,21 @@ describe 'scopable', ->
49
48
  describe '#(name, type)', ->
50
49
 
51
50
  it 'should add scope methods to model', ->
52
- person.scope 'bissexual', Boolean
53
- person.bissexual.should.be.function
51
+ @person.scope 'bissexual', Boolean
52
+ @person.bissexual.should.be.function
54
53
 
55
54
  describe '#{generated_scope}', ->
56
- deferred = null
57
55
 
58
56
  beforeEach ->
59
- deferred = jQuery.Deferred()
60
- sinon.stub(jQuery, "ajax").returns deferred
61
- person.scope.clear()
57
+ @request = jQuery.Deferred()
58
+ sinon.stub(jQuery, "ajax").returns @request
59
+ @person.scope.clear()
62
60
 
63
61
  afterEach -> jQuery.ajax.restore()
64
62
 
65
- describe '#all', ->
66
- deferred = promises = person = null
63
+ describe '#every', ->
67
64
 
68
- it 'should return models when promise is resolved', (done) ->
65
+ it 'should fetch models from the server', (done) ->
69
66
 
70
67
  # Will be called once for each saved record
71
68
  fetched = (people) ->
@@ -73,29 +70,30 @@ describe 'scopable', ->
73
70
  people[0].name.should.be.string
74
71
  done()
75
72
 
76
- person.every fetched
73
+ @person.every fetched
77
74
 
78
- deferred.resolveWith person, [[{name: 'Arthur'}, {name: 'Ford'}]]
75
+ # TODO rename deferred to @request
76
+ @request.resolveWith @person, [[{name: 'Arthur'}, {name: 'Ford'}]]
79
77
  jQuery.ajax.callCount.should.be.eq 1
80
78
 
81
79
 
82
80
  describe 'when string', ->
83
81
  it 'should acumulate data in scope object', ->
84
- person.by_name()
85
- person.scope.data.by_name.should.be.a 'string'
82
+ @person.by_name()
83
+ @person.scope.data.by_name.should.be.a 'string'
86
84
 
87
85
  it 'should override data throught parameters', ->
88
- person.by_name 'Ford'
89
- person.scope.data.by_name.should.be.eq 'Ford'
86
+ @person.by_name 'Ford'
87
+ @person.scope.data.by_name.should.be.eq 'Ford'
90
88
 
91
89
  describe 'when array', ->
92
90
  it 'should acumulate data in scope object', ->
93
- person.by_type()
94
- person.scope.data.by_type.should.be.a 'array'
91
+ @person.by_type()
92
+ @person.scope.data.by_type.should.be.a 'array'
95
93
 
96
94
  it 'should override data throught parameters', ->
97
- person.by_type 1, 2, 3
98
- person.scope.data.by_type.should.contain 1, 2, 3
95
+ @person.by_type 1, 2, 3
96
+ @person.scope.data.by_type.should.contain 1, 2, 3
99
97
 
100
98
  it 'should use default value'
101
99
  it 'should allow scope chaining'
@@ -103,7 +101,7 @@ describe 'scopable', ->
103
101
  describe 'xhr request', ->
104
102
 
105
103
  it 'should build correct url', ->
106
- person.by_type(1, 3, 4).fetch()
104
+ @person.by_type(1, 3, 4).fetch()
107
105
 
108
106
  settings = jQuery.ajax.firstCall.args[0]
109
107
 
@@ -112,38 +110,37 @@ describe 'scopable', ->
112
110
  settings.data.by_type.should.include 1, 3, 4
113
111
 
114
112
  it 'should make call', ->
115
- person.by_type(1, 3, 4).fetch()
113
+ @person.by_type(1, 3, 4).fetch()
116
114
  jQuery.ajax.callCount.should.be.eq 1
117
115
 
118
116
 
119
117
  describe 'when boolean', ->
120
118
 
121
119
  it 'should acumulate data in scope object', ->
122
- person.hetero()
123
- person.scope.data.hetero.should.be.eq true
120
+ @person.hetero()
121
+ @person.scope.data.hetero.should.be.eq true
124
122
 
125
123
  it 'should override data throught parameters', ->
126
- person.hetero false
127
- person.scope.data.hetero.should.be.eq false
124
+ @person.hetero false
125
+ @person.scope.data.hetero.should.be.eq false
128
126
 
129
127
  it 'should allow scope chaining'
130
128
 
131
129
  it 'should make ajax call', ->
132
- person.hetero().fetch()
130
+ @person.hetero().fetch()
133
131
  jQuery.ajax.callCount.should.be.eq 1
134
132
 
135
133
  describe '#{generated_association}', ->
136
134
 
137
135
  describe 'of type belongs_to', ->
138
- towel = null
139
136
 
140
137
  beforeEach ->
141
- person = model.call
138
+ @person = model.call
142
139
  $hetero: true
143
140
  $by_type: []
144
141
  resource: 'person'
145
142
 
146
- towel = model.call
143
+ @towel = model.call
147
144
  resource: 'towel'
148
145
  material: 'cotton'
149
146
  belongs_to: 'person'
@@ -152,7 +149,7 @@ describe 'scopable', ->
152
149
  describe '#{generated_scope}', ->
153
150
 
154
151
  it 'can be called on association', ->
155
- soft_towel = towel
152
+ soft_towel = @towel
156
153
  material: 'silicon microfiber'
157
154
 
158
155
  soft_towel.build_person()
@@ -160,32 +157,68 @@ describe 'scopable', ->
160
157
  expect(soft_towel.person).to.respondTo 'hetero'
161
158
 
162
159
  describe 'of type has_many', ->
163
- arthur = towel = null
164
160
 
165
161
  beforeEach ->
166
- person = model.call
162
+ @person = model.call
167
163
  $hetero: true
168
164
  $by_type: []
169
165
  resource: 'person'
170
166
  has_many: 'towels'
171
167
 
172
- towel = model.call
168
+ @towel = model.call
173
169
  $by_material: []
174
170
  resource: 'towel'
175
171
  material: 'cotton'
176
172
  belongs_to: 'person'
177
173
 
178
- arthur = person
174
+ @arthur = @person
179
175
  name: 'Arthur'
180
176
 
181
-
177
+ @person.scope.clear()
182
178
 
183
179
  describe '#{generated_scope}', ->
184
180
 
185
181
  it 'can be called on association', ->
186
- expect(arthur.towels).to.respondTo 'by_material'
182
+ expect(@arthur.towels).to.respondTo 'by_material'
187
183
 
188
184
  it 'should be serializable into paramenters', ->
189
- arthur.towels.by_material 'cotton', 'microfiber'
190
- query_string = decodeURIComponent(jQuery.param arthur.towels.scope.data)
185
+ @arthur.towels.by_material 'cotton', 'microfiber'
186
+ query_string = decodeURIComponent(jQuery.param @arthur.towels.scope.data)
191
187
  query_string.should.be.eq 'by_material[]=cotton&by_material[]=microfiber'
188
+
189
+ describe '#every', ->
190
+
191
+ it 'should empty association when no models are returned', (done) ->
192
+
193
+ # Will be called once for each saved record
194
+ fetched = (towels) =>
195
+ towels.should.be.array
196
+ towels.should.be.empty
197
+ @arthur.towels.should.have.length 0
198
+ ` this.should.have.length(0) `
199
+ done()
200
+
201
+ @arthur.towels.every fetched
202
+
203
+ @request.resolveWith @arthur.towels, [[]]
204
+ jQuery.ajax.callCount.should.be.eq 1
205
+
206
+ it 'should update resources when already exists in association', (done) ->
207
+ aditions = @arthur.towels.add _id: 1, material: 'colan'
208
+
209
+ # Will be called once for each saved record
210
+ fetched = (towels) =>
211
+ towels.should.be.array
212
+ towels.should.have.length 1
213
+ towels[0].material.should.be.eq 'cotton'
214
+
215
+ # Updated the associated object, instead of
216
+ # creating a new one
217
+ aditions[0].material.should.be.eq 'cotton'
218
+ @arthur.towels[0].material.should.be.eq 'cotton'
219
+ done()
220
+
221
+ @arthur.towels.every fetched
222
+
223
+ @request.resolveWith @arthur.towels, [[_id: 1, material: 'cotton']]
224
+ jQuery.ajax.callCount.should.be.eq 1
@@ -6,22 +6,21 @@ describe 'model #() validates_cpf_format', ->
6
6
 
7
7
  describe 'basic usage', ->
8
8
  model = root.model
9
- person = null
10
9
 
11
10
  beforeEach ->
12
- person = model.call
11
+ @person = model.call
13
12
  resource : 'person'
14
13
  cpf : String
15
14
  validates_cpf_format: 'cpf'
16
15
 
17
16
  afterEach ->
18
17
  # Clear validators from resource
19
- person?.validators.length = 0
18
+ @person.validators.length = 0
20
19
 
21
20
  describe '#validate', ->
22
21
 
23
22
  it 'should add error to record when fields is in invalid format', ->
24
- arthur = person cpf: '871.943.417-00'
23
+ arthur = @person cpf: '871.95FRANGO-00'
25
24
  arthur.valid
26
25
 
27
26
  # TODO figure out why the heck the validators aren't being reset
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ende
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.18
4
+ version: 0.4.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heitor Salazar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler