ende 0.5.20 → 0.5.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/component.json +1 -1
  3. data/components/indefinido/indemma/master/.gitignore +17 -0
  4. data/components/indefinido/indemma/master/.ruby-gemset +1 -0
  5. data/components/indefinido/indemma/master/.ruby-version +1 -0
  6. data/components/indefinido/indemma/master/Gemfile +12 -0
  7. data/components/indefinido/indemma/master/Guardfile +39 -0
  8. data/components/indefinido/indemma/master/History.md +0 -0
  9. data/components/indefinido/indemma/master/Readme.md +445 -0
  10. data/components/indefinido/indemma/master/build/development.js +26123 -0
  11. data/components/indefinido/indemma/master/build/release.js +16741 -0
  12. data/components/indefinido/indemma/master/build/test.js +26123 -0
  13. data/components/indefinido/indemma/master/component.json +1 -1
  14. data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/component.json +18 -0
  15. data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/index.js +110 -0
  16. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.gitignore +22 -0
  17. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.mailmap +1 -0
  18. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.npmignore +14 -0
  19. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.travis.yml +14 -0
  20. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/CONTRIBUTING.md +173 -0
  21. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/History.md +895 -0
  22. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/Makefile +93 -0
  23. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/README.md +99 -0
  24. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/ReleaseNotes.md +482 -0
  25. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/bower.json +27 -0
  26. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/chai.js +4782 -0
  27. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/component.json +50 -0
  28. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/index.js +1 -0
  29. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.conf.js +28 -0
  30. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.sauce.js +41 -0
  31. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/assertion.js +130 -0
  32. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/config.js +50 -0
  33. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/core/assertions.js +1314 -0
  34. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/assert.js +1056 -0
  35. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/expect.js +12 -0
  36. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/should.js +78 -0
  37. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addChainableMethod.js +111 -0
  38. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addMethod.js +43 -0
  39. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addProperty.js +40 -0
  40. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/flag.js +32 -0
  41. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getActual.js +18 -0
  42. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getEnumerableProperties.js +25 -0
  43. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getMessage.js +49 -0
  44. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getName.js +20 -0
  45. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getPathValue.js +102 -0
  46. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getProperties.js +35 -0
  47. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/index.js +114 -0
  48. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/inspect.js +320 -0
  49. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/objDisplay.js +49 -0
  50. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteChainableMethod.js +53 -0
  51. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteMethod.js +51 -0
  52. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteProperty.js +54 -0
  53. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/test.js +26 -0
  54. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/transferFlags.js +44 -0
  55. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/type.js +45 -0
  56. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai.js +87 -0
  57. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/package.json +42 -0
  58. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/sauce.browsers.js +128 -0
  59. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_block.sh +7 -0
  60. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_setup.sh +53 -0
  61. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/assert.js +638 -0
  62. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/auth/.gitkeep +0 -0
  63. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/index.js +22 -0
  64. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/karma.js +22 -0
  65. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/configuration.js +133 -0
  66. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/errors.js +14 -0
  67. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/message.js +47 -0
  68. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/expect.js +814 -0
  69. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/globalShould.js +15 -0
  70. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/plugins.js +24 -0
  71. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/should.js +744 -0
  72. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/utilities.js +309 -0
  73. data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/component.json +20 -0
  74. data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/lib/eql.js +257 -0
  75. data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/component.json +18 -0
  76. data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/lib/type.js +142 -0
  77. data/components/indefinido/indemma/master/components/component/bind/1.0.0/component.json +14 -0
  78. data/components/indefinido/indemma/master/components/component/bind/1.0.0/index.js +23 -0
  79. data/components/indefinido/indemma/master/components/component/jquery/1.0.0/component.json +10 -0
  80. data/components/indefinido/indemma/master/components/component/jquery/1.0.0/index.js +10308 -0
  81. data/components/indefinido/indemma/master/components/component/type/1.0.0/component.json +20 -0
  82. data/components/indefinido/indemma/master/components/component/type/1.0.0/index.js +32 -0
  83. data/components/indefinido/indemma/master/components/indefinido/advisable/master/component.json +21 -0
  84. data/components/indefinido/indemma/master/components/indefinido/advisable/master/index.js +1 -0
  85. data/components/indefinido/indemma/master/components/indefinido/advisable/master/lib/advisable.js +60 -0
  86. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/component.json +39 -0
  87. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/index.js +1 -0
  88. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/adapters/rivets.js +40 -0
  89. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/notifierable.js +145 -0
  90. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +147 -0
  91. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/lookup.js +38 -0
  92. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/keypath_observer.js +38 -0
  93. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/observation.js +45 -0
  94. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/selection.js +57 -0
  95. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/self_observer.js +38 -0
  96. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable.js +97 -0
  97. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/platform.js +12 -0
  98. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/observe-js/observe.js +1631 -0
  99. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors-legacy.js +92 -0
  100. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors.js +248 -0
  101. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/array.indexOf.js +8 -0
  102. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/object.create.js +77 -0
  103. data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/component.json +25 -0
  104. data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/dist/assimilate.js +127 -0
  105. data/components/indefinido/indemma/master/karma.conf.js +75 -0
  106. data/components/indefinido/indemma/master/lib/record/associable.js +4 -2
  107. data/components/indefinido/indemma/master/lib/record/dirtyable.js +1 -1
  108. data/components/indefinido/indemma/master/package.json +9 -0
  109. data/components/indefinido/indemma/master/spec/record/associable_spec.js +211 -0
  110. data/components/indefinido/indemma/master/spec/record/dirtyable_spec.js +57 -0
  111. data/components/indefinido/indemma/master/spec/record/maid_spec.js +40 -0
  112. data/components/indefinido/indemma/master/spec/record/persistable_spec.js +46 -0
  113. data/components/indefinido/indemma/master/spec/record/queryable_spec.js +39 -0
  114. data/components/indefinido/indemma/master/spec/record/resource_spec.js +93 -0
  115. data/components/indefinido/indemma/master/spec/record/rest_spec.js +32 -0
  116. data/components/indefinido/indemma/master/spec/record/restfulable_spec.js +346 -0
  117. data/components/indefinido/indemma/master/spec/record/scopable_spec.js +242 -0
  118. data/components/indefinido/indemma/master/spec/record/storable_spec.js +44 -0
  119. data/components/indefinido/indemma/master/spec/record/translationable.js +28 -0
  120. data/components/indefinido/indemma/master/spec/record/validatable_spec.js +142 -0
  121. data/components/indefinido/indemma/master/spec/record/validations/associated_spec.js +43 -0
  122. data/components/indefinido/indemma/master/spec/record/validations/confirmation_spec.js +36 -0
  123. data/components/indefinido/indemma/master/spec/record/validations/cpf_spec.js +34 -0
  124. data/components/indefinido/indemma/master/spec/record/validations/presence_spec.js +28 -0
  125. data/components/indefinido/indemma/master/spec/record/validations/remote_spec.js +87 -0
  126. data/components/indefinido/indemma/master/spec/record/validations/type_spec.js +48 -0
  127. data/components/indefinido/indemma/master/spec/record_spec.js +49 -0
  128. data/components/indefinido/indemma/master/spec/spec_helper.js +15 -0
  129. data/components/indefinido/indemma/master/spec/support/value_objects/phone.js +45 -0
  130. data/components/indefinido/indemma/master/src/lib/extensions/rivets.coffee +17 -0
  131. data/components/indefinido/indemma/master/src/lib/record/associable.coffee +419 -0
  132. data/components/indefinido/indemma/master/src/lib/record/dirtyable.coffee +47 -0
  133. data/components/indefinido/indemma/master/src/lib/record/errors.coffee +20 -0
  134. data/components/indefinido/indemma/master/src/lib/record/maid.coffee +16 -0
  135. data/components/indefinido/indemma/master/src/lib/record/persistable.coffee +34 -0
  136. data/components/indefinido/indemma/master/src/lib/record/queryable.coffee +29 -0
  137. data/components/indefinido/indemma/master/src/lib/record/resource.coffee +107 -0
  138. data/components/indefinido/indemma/master/src/lib/record/rest.coffee +34 -0
  139. data/components/indefinido/indemma/master/src/lib/record/restfulable.coffee +487 -0
  140. data/components/indefinido/indemma/master/src/lib/record/scopable.coffee +279 -0
  141. data/components/indefinido/indemma/master/src/lib/record/storable.coffee +49 -0
  142. data/components/indefinido/indemma/master/src/lib/record/translationable.coffee +18 -0
  143. data/components/indefinido/indemma/master/src/lib/record/validatable.coffee +241 -0
  144. data/components/indefinido/indemma/master/src/lib/record/validations/associated.coffee +34 -0
  145. data/components/indefinido/indemma/master/src/lib/record/validations/confirmation.coffee +17 -0
  146. data/components/indefinido/indemma/master/src/lib/record/validations/cpf.coffee +57 -0
  147. data/components/indefinido/indemma/master/src/lib/record/validations/presence.coffee +16 -0
  148. data/components/indefinido/indemma/master/src/lib/record/validations/remote.coffee +61 -0
  149. data/components/indefinido/indemma/master/src/lib/record/validations/type.coffee +31 -0
  150. data/components/indefinido/indemma/master/src/lib/record/validations/validatorable.coffee +5 -0
  151. data/components/indefinido/indemma/master/src/lib/record.coffee +143 -0
  152. data/components/indefinido/indemma/master/src/spec/record/associable_spec.coffee +205 -0
  153. data/components/indefinido/indemma/master/src/spec/record/dirtyable_spec.coffee +47 -0
  154. data/components/indefinido/indemma/master/src/spec/record/maid_spec.coffee +34 -0
  155. data/components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee +39 -0
  156. data/components/indefinido/indemma/master/src/spec/record/queryable_spec.coffee +33 -0
  157. data/components/indefinido/indemma/master/src/spec/record/resource_spec.coffee +69 -0
  158. data/components/indefinido/indemma/master/src/spec/record/rest_spec.coffee +22 -0
  159. data/components/indefinido/indemma/master/src/spec/record/restfulable_spec.coffee +257 -0
  160. data/components/indefinido/indemma/master/src/spec/record/scopable_spec.coffee +227 -0
  161. data/components/indefinido/indemma/master/src/spec/record/storable_spec.coffee +39 -0
  162. data/components/indefinido/indemma/master/src/spec/record/translationable.coffee +19 -0
  163. data/components/indefinido/indemma/master/src/spec/record/validatable_spec.coffee +127 -0
  164. data/components/indefinido/indemma/master/src/spec/record/validations/associated_spec.coffee +35 -0
  165. data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee +25 -0
  166. data/components/indefinido/indemma/master/src/spec/record/validations/cpf_spec.coffee +27 -0
  167. data/components/indefinido/indemma/master/src/spec/record/validations/presence_spec.coffee +24 -0
  168. data/components/indefinido/indemma/master/src/spec/record/validations/remote_spec.coffee +74 -0
  169. data/components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee +33 -0
  170. data/components/indefinido/indemma/master/src/spec/record_spec.coffee +29 -0
  171. data/components/indefinido/indemma/master/src/spec/spec_helper.coffee +11 -0
  172. data/components/indefinido/indemma/master/src/spec/support/value_objects/phone.coffee +30 -0
  173. data/components/indefinido/indemma/master/vendor/object/mixin.js +196 -0
  174. data/components/indefinido/indemma/master/vendor/spec/sinon/assert.js +199 -0
  175. data/components/indefinido/indemma/master/vendor/spec/sinon/behavior.js +334 -0
  176. data/components/indefinido/indemma/master/vendor/spec/sinon/call.js +205 -0
  177. data/components/indefinido/indemma/master/vendor/spec/sinon/collection.js +155 -0
  178. data/components/indefinido/indemma/master/vendor/spec/sinon/match.js +245 -0
  179. data/components/indefinido/indemma/master/vendor/spec/sinon/mock.js +451 -0
  180. data/components/indefinido/indemma/master/vendor/spec/sinon/sandbox.js +144 -0
  181. data/components/indefinido/indemma/master/vendor/spec/sinon/spy.js +413 -0
  182. data/components/indefinido/indemma/master/vendor/spec/sinon/stub.js +161 -0
  183. data/components/indefinido/indemma/master/vendor/spec/sinon/test.js +77 -0
  184. data/components/indefinido/indemma/master/vendor/spec/sinon/test_case.js +99 -0
  185. data/components/indefinido/indemma/master/vendor/spec/sinon/util/event.js +94 -0
  186. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server.js +212 -0
  187. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server_with_clock.js +83 -0
  188. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_timers.js +405 -0
  189. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xdomain_request.js +206 -0
  190. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xml_http_request.js +575 -0
  191. data/components/indefinido/indemma/master/vendor/spec/sinon/util/timers_ie.js +31 -0
  192. data/components/indefinido/indemma/master/vendor/spec/sinon/util/xdr_ie.js +14 -0
  193. data/components/indefinido/indemma/master/vendor/spec/sinon/util/xhr_ie.js +19 -0
  194. data/components/indefinido/indemma/master/vendor/spec/sinon.js +383 -0
  195. data/lib/assets/javascripts/value_objects/phone.js.coffee +3 -1
  196. data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +5 -5
  197. data/lib/ende/version.rb +1 -1
  198. data/vendor/assets/components/ende_build.css +4 -4
  199. data/vendor/assets/components/ende_build.js +7974 -7889
  200. metadata +191 -5
  201. data/vendor/assets/component/build.css +0 -112
  202. data/vendor/assets/components/build.css +0 -112
  203. data/vendor/assets/components/indemma_with_none.js +0 -30553
@@ -0,0 +1,211 @@
1
+ var $, root;
2
+
3
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
4
+
5
+ require('indemma/lib/record/associable.js');
6
+
7
+ $ = require('jquery');
8
+
9
+ describe('record', function() {
10
+ var record;
11
+
12
+ record = root.record;
13
+ return it('should create a record');
14
+ });
15
+
16
+ describe('model', function() {
17
+ var arthur, corporation, model, person, radio;
18
+
19
+ model = root.model;
20
+ arthur = radio = null;
21
+ person = corporation = null;
22
+ beforeEach(function() {
23
+ var ford, friend;
24
+
25
+ corporation = model.call({
26
+ resource: 'corporation'
27
+ });
28
+ friend = model.call({
29
+ resource: 'friends'
30
+ });
31
+ person = model.call({
32
+ resource: 'person',
33
+ has_many: 'friends',
34
+ belongs_to: 'corporation'
35
+ });
36
+ radio = corporation({
37
+ _id: 1,
38
+ name: 'Local Radio'
39
+ });
40
+ ford = friend({
41
+ _id: 2,
42
+ name: 'Ford Perfect'
43
+ });
44
+ return this.arthur = arthur = person({
45
+ _id: 3,
46
+ name: 'Arthur Philip Dent'
47
+ });
48
+ });
49
+ describe('has_one', function() {
50
+ return it('should add a has_one property with the associations descriptions', function() {
51
+ return $.type(person.has_one).should.be.eq('array');
52
+ });
53
+ });
54
+ describe('belongs_to', function() {
55
+ it('should add a belongs_to property with the associations descriptions', function() {
56
+ return $.type(person.belongs_to).should.be.eq('array');
57
+ });
58
+ describe("{associated}_id", function() {
59
+ xdescribe('with autobuild option on the asssociation', function() {
60
+ return xit('should return an partial resource when acessing associated', function() {
61
+ this.arthur.corporation_id = radio._id;
62
+ this.arthur.should.have.property('corporation');
63
+ this.arthur.corporation.should.be.object;
64
+ this.arthur.corporation.should.have.property('resource');
65
+ return this.arthur.corporation.should.have.property('_id', radio._id);
66
+ });
67
+ });
68
+ xit('should fetch the resource when accessing associated and resource not present', function(done) {
69
+ radio = corporation({
70
+ _id: 1,
71
+ name: 'Local Radio'
72
+ });
73
+ this.arthur.corporation_id = radio._id;
74
+ this.arthur.corporation.should.be.object;
75
+ this.arthur.corporation.should.have.property('resource', radio.resource);
76
+ this.arthur.corporation._id.should.be(null);
77
+ this.arthur.corporation.locking.should.be.object;
78
+ return this.arthur.corporation.locking.done(function(corporation) {
79
+ corporation.should.have.property('_id', radio.id);
80
+ return corporation.should.have.property('name', radio.name);
81
+ });
82
+ });
83
+ it('should notify changes', function() {
84
+ var subscribed, subscribed_id;
85
+
86
+ radio = corporation({
87
+ _id: 1,
88
+ name: 'Local Radio'
89
+ });
90
+ subscribed_id = sinon.spy();
91
+ subscribed = sinon.spy();
92
+ this.arthur.subscribe('corporation_id', subscribed_id);
93
+ this.arthur.subscribe('corporation', subscribed);
94
+ this.arthur.corporation_id = radio._id;
95
+ this.arthur.observation.deliver();
96
+ this.arthur.corporation_id = null;
97
+ this.arthur.observation.deliver();
98
+ subscribed.called.should.be["true"];
99
+ subscribed.callCount.should.be.eq(2);
100
+ subscribed_id.called.should.be["true"];
101
+ return subscribed_id.callCount.should.be.eq(2);
102
+ });
103
+ return it('should remove {associated} when nulifying', function() {
104
+ var subscribed;
105
+
106
+ radio = corporation({
107
+ _id: 1,
108
+ name: 'Local Radio'
109
+ });
110
+ subscribed = sinon.spy();
111
+ this.arthur.subscribe('corporation_id', subscribed);
112
+ this.arthur.corporation_id = radio._id;
113
+ this.arthur.observation.deliver();
114
+ this.arthur.corporation_id = null;
115
+ this.arthur.observation.deliver();
116
+ subscribed.called.should.be["true"];
117
+ subscribed.callCount.should.be.eq(2);
118
+ this.arthur.should.have.property('corporation_id', null);
119
+ return this.arthur.should.have.property('corporation', null);
120
+ });
121
+ });
122
+ describe("{associated}", function() {
123
+ describe('with autoload option on the association', function() {
124
+ return it('should create associated when sustained and stored', function() {
125
+ radio.sustained.should.be["true"];
126
+ this.arthur.corporation_id = radio._id;
127
+ return this.arthur.should.have.property('corporation', radio);
128
+ });
129
+ });
130
+ it('should update {associated_id} and record when associated record changes', function() {
131
+ radio = corporation({
132
+ _id: 1,
133
+ name: 'Local Radio',
134
+ sustained: true
135
+ });
136
+ expect(this.arthur.corporation).to.be["null"];
137
+ this.arthur.corporation = radio;
138
+ this.arthur.corporation_id;
139
+ this.arthur.should.have.property('corporation', radio);
140
+ this.arthur.should.have.property('corporation_id', radio._id);
141
+ this.arthur.corporation = null;
142
+ this.arthur.observation.deliver();
143
+ this.arthur.should.have.property('corporation', null);
144
+ return this.arthur.should.have.property('corporation_id', null);
145
+ });
146
+ return it('should notify changes', function() {
147
+ var subscribed, subscribed_id;
148
+
149
+ radio = corporation({
150
+ _id: 1,
151
+ name: 'Local Radio'
152
+ });
153
+ subscribed = sinon.spy();
154
+ subscribed_id = sinon.spy();
155
+ this.arthur.subscribe('corporation', subscribed);
156
+ this.arthur.subscribe('corporation_id', subscribed_id);
157
+ this.arthur.corporation = radio;
158
+ this.arthur.observation.deliver();
159
+ this.arthur.corporation = null;
160
+ this.arthur.observation.deliver();
161
+ subscribed.called.should.be["true"];
162
+ subscribed.callCount.should.be.eq(2);
163
+ subscribed_id.called.should.be["true"];
164
+ return subscribed_id.callCount.should.be.eq(2);
165
+ });
166
+ });
167
+ return describe("#build_{associated}", function() {
168
+ return it('should add builded object to association named attribute', function() {
169
+ this.arthur = person({
170
+ name: 'Arthur Dent'
171
+ });
172
+ corporation = this.arthur.build_corporation();
173
+ this.arthur.should.have.property('corporation');
174
+ return expect(corporation).to.be.ok;
175
+ });
176
+ });
177
+ });
178
+ return describe('has_many', function() {
179
+ it('should add a has_many property with the associations descriptions', function() {
180
+ return $.type(person.has_many).should.be.eq('array');
181
+ });
182
+ it('should return a record factory with associations stored', function() {
183
+ var has_many;
184
+
185
+ person.has_many.should.be.array;
186
+ has_many = Array.prototype.splice.call(person.has_many, 0);
187
+ return has_many.should.contain('friends');
188
+ });
189
+ return describe('#()', function() {
190
+ it('should return a record with an association object', function() {
191
+ return person().should.have.property('friends');
192
+ });
193
+ return describe('{generated_association}', function() {
194
+ var association;
195
+
196
+ association = null;
197
+ beforeEach(function() {
198
+ return association = person().friends;
199
+ });
200
+ it('should have query methods', function() {
201
+ association.should.have.property('find');
202
+ association.should.have.property('each');
203
+ return association.should.have.property('reload');
204
+ });
205
+ return describe('#every', function() {
206
+ return it('should auto observe nested associations attributes');
207
+ });
208
+ });
209
+ });
210
+ });
211
+ });
@@ -0,0 +1,57 @@
1
+ var jQuery, model, record, root;
2
+
3
+ require('indemma/lib/record/restfulable.js');
4
+
5
+ require('indemma/lib/record/dirtyable.js');
6
+
7
+ 'use strict';
8
+
9
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
10
+
11
+ model = root.model;
12
+
13
+ record = root.record;
14
+
15
+ jQuery = require('component-jquery');
16
+
17
+ describe('dirtyable', function() {
18
+ describe('when included', function() {
19
+ return it('sets te dirtyable loaded flag on model', function() {
20
+ return model.dirtyable.should.be["true"];
21
+ });
22
+ });
23
+ describe('record', function() {
24
+ return describe('()', function() {
25
+ beforeEach(function() {
26
+ this.person = model.call({
27
+ resource: 'person'
28
+ });
29
+ return this.arthur = this.person({
30
+ name: 'Arthur Philip Dent'
31
+ });
32
+ });
33
+ describe('.dirty', function() {
34
+ it('should exist after initialization', function() {
35
+ return this.arthur.should.have.property('dirty');
36
+ });
37
+ return it('should be true on record changes', function() {
38
+ this.arthur.name = 10;
39
+ this.arthur.observation.deliver();
40
+ return this.arthur.dirty.should.be["true"];
41
+ });
42
+ });
43
+ return describe('.saved()', function() {
44
+ beforeEach(function() {
45
+ return sinon.stub(jQuery, "ajax").returns(jQuery.Deferred());
46
+ });
47
+ afterEach(function() {
48
+ return jQuery.ajax.restore();
49
+ });
50
+ return it('should clean record after', function() {});
51
+ });
52
+ });
53
+ });
54
+ return describe('model', function() {
55
+ return describe('()', function() {});
56
+ });
57
+ });
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+ var maid;
3
+
4
+ maid = require('indemma/lib/record/maid.js');
5
+
6
+ describe('maid', function() {
7
+ beforeEach(function() {
8
+ return this.personable = model.call({
9
+ resource: 'person',
10
+ washing: true
11
+ });
12
+ });
13
+ it('should save upon record dirtying', function(done) {
14
+ var _this = this;
15
+
16
+ this.arthur = this.personable({
17
+ name: 'Arthur Dent'
18
+ });
19
+ sinon.stub(this.arthur, 'save').returns(true);
20
+ this.arthur.name = 'Arthur Philip Dent';
21
+ return setTimeout(function() {
22
+ _this.arthur.save.called.should.be["true"];
23
+ return done();
24
+ }, 1000);
25
+ });
26
+ return it('should not save upon record creation', function(done) {
27
+ var _this = this;
28
+
29
+ this.timeout(10000);
30
+ sinon.stub(jQuery, "ajax").returns(jQuery.Deferred());
31
+ this.arthur = this.personable({
32
+ name: 'Arthur Dent'
33
+ });
34
+ return setTimeout(function() {
35
+ jQuery.ajax.called.should.be["false"];
36
+ jQuery.ajax.restore();
37
+ return done();
38
+ }, 2000);
39
+ });
40
+ });
@@ -0,0 +1,46 @@
1
+ var root;
2
+
3
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
4
+
5
+ require('indemma/lib/record/persistable.js');
6
+
7
+ describe('persistable', function() {
8
+ return describe('model', function() {
9
+ it('should set the persistable key', function() {
10
+ return model.should.have.property('persistable', true);
11
+ });
12
+ return describe('#find', function() {
13
+ beforeEach(function() {
14
+ this.xhr = jQuery.Deferred();
15
+ sinon.stub(jQuery, "ajax").returns(this.xhr);
16
+ this.personable = model.call({
17
+ resource: 'person',
18
+ has_many: 'friends',
19
+ belongs_to: 'corporation'
20
+ });
21
+ this.arthur = this.personable({
22
+ name: 'Arthur Philip Dent'
23
+ });
24
+ this.xhr.resolveWith(this.arthur, [
25
+ {
26
+ _id: 1
27
+ }
28
+ ]);
29
+ return this.arthur.dirty = true;
30
+ });
31
+ afterEach(function() {
32
+ return jQuery.ajax.restore();
33
+ });
34
+ return it('should try to store a record after saving when initialzed without id', function(done) {
35
+ var _this = this;
36
+
37
+ sinon.stub(this.personable.storage, 'store').returns(true);
38
+ this.arthur.save(function() {
39
+ expect(_this.personable.storage.store.calledOnce).to.be["true"];
40
+ return done();
41
+ });
42
+ return this.personable.storage.store.restore();
43
+ });
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,39 @@
1
+ var queryable, root;
2
+
3
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
4
+
5
+ queryable = require('indemma/lib/record/queryable.js');
6
+
7
+ describe('queryable', function() {
8
+ return describe('model', function() {
9
+ beforeEach(function() {
10
+ return this.personable = model.call({
11
+ resource: 'person'
12
+ });
13
+ });
14
+ it('should set the queryable key', function() {
15
+ return model.should.have.property('queryable', true);
16
+ });
17
+ it('should create a storage', function() {
18
+ return this.personable.should.have.property('storage');
19
+ });
20
+ return describe('#find', function() {
21
+ beforeEach(function() {
22
+ this.xhr = jQuery.Deferred();
23
+ sinon.stub(jQuery, "ajax").returns(this.xhr);
24
+ this.arthur = this.personable({
25
+ _id: '1',
26
+ name: 'Arthur Philip Dent'
27
+ });
28
+ this.arthur.save();
29
+ return this.xhr.resolveWith(this.arthur, [this.arthur.json()]);
30
+ });
31
+ afterEach(function() {
32
+ return jQuery.ajax.restore();
33
+ });
34
+ return it('should retrieve a record by key', function() {
35
+ return this.personable.find('1').should.have.property('name', this.arthur.name);
36
+ });
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,93 @@
1
+ var jQuery, model, record, root;
2
+
3
+ require('indemma/lib/record/restfulable.js');
4
+
5
+ require('indemma/lib/record/resource.js');
6
+
7
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
8
+
9
+ model = root.model;
10
+
11
+ record = root.record;
12
+
13
+ jQuery = require('component-jquery');
14
+
15
+ describe('resource', function() {
16
+ describe('with scope option', function() {
17
+ var person, towel;
18
+
19
+ person = towel = null;
20
+ beforeEach(function() {
21
+ person = model.call({
22
+ resource: 'person'
23
+ });
24
+ return towel = model.call({
25
+ resource: {
26
+ name: 'towel',
27
+ scope: 'users'
28
+ }
29
+ });
30
+ });
31
+ return it('should be prefixed with scope', function() {
32
+ towel.route.should.be.eq('/users/towels');
33
+ towel({}).route.should.be.eq('/users/towels');
34
+ return towel({
35
+ id: 1
36
+ }).route.should.be.eq('/users/towels');
37
+ });
38
+ });
39
+ describe('with singular resource', function() {
40
+ var towel;
41
+
42
+ towel = null;
43
+ beforeEach(function() {
44
+ var context, deferred, promises;
45
+
46
+ towel = model.call({
47
+ resource: {
48
+ name: 'towel',
49
+ singular: true
50
+ }
51
+ });
52
+ deferred = jQuery.Deferred();
53
+ context = towel({
54
+ name: 'Arthur Philip Dent'
55
+ });
56
+ context.lock = JSON.stringify(context.json());
57
+ deferred.resolveWith(context, [
58
+ {
59
+ _id: 1,
60
+ name: 'Arthur Philip Dent'
61
+ }
62
+ ]);
63
+ sinon.stub(jQuery, "ajax").returns(deferred);
64
+ return promises = towel.create({
65
+ name: 'Arthur Philip Dent'
66
+ }, {
67
+ name: 'Ford'
68
+ });
69
+ });
70
+ afterEach(function() {
71
+ return jQuery.ajax.restore();
72
+ });
73
+ return it('the route should be in singular form', function() {
74
+ towel.route.should.be.eq('/towel');
75
+ towel({}).route.should.be.eq('/towel');
76
+ return towel({
77
+ id: 1
78
+ }).route.should.be.eq('/towel');
79
+ });
80
+ });
81
+ describe('when included', function() {
82
+ return xit('sets the resource loaded flag on model', function() {});
83
+ });
84
+ return describe('model', function() {
85
+ it('add methods to model object');
86
+ describe('#pluralize', function() {
87
+ return xit('transforms word into plural form');
88
+ });
89
+ return describe('#singularize', function() {
90
+ return xit('transforms word into singular form');
91
+ });
92
+ });
93
+ });
@@ -0,0 +1,32 @@
1
+ var jQuery, rest, root;
2
+
3
+ require('indemma/lib/record/resource.js');
4
+
5
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
6
+
7
+ rest = require('indemma/lib/record/rest.js');
8
+
9
+ jQuery = require('component-jquery');
10
+
11
+ describe('rest', function() {
12
+ var object;
13
+
14
+ object = null;
15
+ beforeEach(function() {
16
+ object = Object.create(rest);
17
+ object.route = "users";
18
+ return object.resource = "user";
19
+ });
20
+ beforeEach(function() {
21
+ return sinon.stub(jQuery, "ajax").returns(jQuery.Deferred());
22
+ });
23
+ afterEach(function() {
24
+ return jQuery.ajax.restore();
25
+ });
26
+ return describe('#delete', function() {
27
+ return it('should make ajax call', function() {
28
+ object["delete"]();
29
+ return jQuery.ajax.called.should.be["true"];
30
+ });
31
+ });
32
+ });