sproutcore 1.0.1003 → 1.0.1008

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. data/Buildfile +15 -3
  2. data/Rakefile +3 -7
  3. data/VERSION.yml +2 -2
  4. data/buildtasks/manifest.rake +2 -0
  5. data/frameworks/sproutcore/Buildfile +2 -0
  6. data/frameworks/sproutcore/HISTORY +218 -203
  7. data/frameworks/sproutcore/README +47 -6
  8. data/frameworks/sproutcore/apps/tests/english.lproj/main_page.css +4 -0
  9. data/frameworks/sproutcore/design/Design Charts.graffle +2945 -4332
  10. data/frameworks/sproutcore/frameworks/bootstrap/README +9 -0
  11. data/frameworks/sproutcore/frameworks/bootstrap/core.js +7 -0
  12. data/frameworks/sproutcore/frameworks/bootstrap/setup_body_class_names.js +10 -0
  13. data/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -0
  14. data/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +45 -0
  15. data/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +9 -8
  16. data/frameworks/sproutcore/frameworks/datastore/models/record.js +49 -9
  17. data/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +9 -0
  18. data/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +3 -2
  19. data/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +81 -8
  20. data/frameworks/sproutcore/frameworks/datastore/system/query.js +26 -5
  21. data/frameworks/sproutcore/frameworks/datastore/system/record_array.js +47 -0
  22. data/frameworks/sproutcore/frameworks/datastore/system/store.js +164 -32
  23. data/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +32 -4
  24. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +56 -0
  25. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/normalize.js +1 -1
  26. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/unknownProperty.js +15 -0
  27. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +16 -1
  28. data/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +1 -1
  29. data/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +22 -1
  30. data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +32 -1
  31. data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/core_methods.js +70 -0
  32. data/frameworks/sproutcore/frameworks/datastore/tests/system/query/evaluation.js +12 -0
  33. data/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +50 -0
  34. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +9 -9
  35. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/core_methods.js +8 -1
  36. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataHashDidChange.js +79 -0
  37. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +24 -0
  38. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/error_methods.js +62 -0
  39. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/init.js +2 -0
  40. data/frameworks/sproutcore/frameworks/debug/core.js +10 -6
  41. data/frameworks/sproutcore/frameworks/designer/controllers/page_design.js +43 -18
  42. data/frameworks/sproutcore/frameworks/designer/core.js +10 -0
  43. data/frameworks/sproutcore/frameworks/designer/english.lproj/selection_handles.css +58 -0
  44. data/frameworks/sproutcore/frameworks/designer/{views/mixins → mixins}/button.js +0 -0
  45. data/frameworks/sproutcore/frameworks/designer/views/{controls/button.js → button.js} +6 -2
  46. data/frameworks/sproutcore/frameworks/designer/views/designer.js +566 -136
  47. data/frameworks/sproutcore/frameworks/designer/views/selection_handles.js +77 -0
  48. data/frameworks/sproutcore/frameworks/desktop/core.js +12 -0
  49. data/frameworks/sproutcore/frameworks/desktop/english.lproj/alert.css +1 -1
  50. data/frameworks/sproutcore/frameworks/desktop/english.lproj/drag.css +3 -2
  51. data/frameworks/sproutcore/frameworks/desktop/english.lproj/list_item.css +0 -36
  52. data/frameworks/sproutcore/frameworks/desktop/english.lproj/menu.css +14 -0
  53. data/frameworks/sproutcore/frameworks/desktop/english.lproj/modal.css +4 -0
  54. data/frameworks/sproutcore/frameworks/desktop/english.lproj/slider.css +2 -0
  55. data/frameworks/sproutcore/frameworks/desktop/english.lproj/tab.css +0 -4
  56. data/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +8 -5
  57. data/frameworks/sproutcore/frameworks/desktop/panes/alert.js +2 -2
  58. data/frameworks/sproutcore/frameworks/desktop/panes/menu.js +100 -111
  59. data/frameworks/sproutcore/frameworks/desktop/panes/panel.js +1 -1
  60. data/frameworks/sproutcore/frameworks/desktop/panes/picker.js +51 -13
  61. data/frameworks/sproutcore/frameworks/desktop/panes/{drop_down.js → select_button.js} +70 -109
  62. data/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +8 -0
  63. data/frameworks/sproutcore/frameworks/desktop/system/root_responder.js +69 -23
  64. data/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +4 -4
  65. data/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +2 -0
  66. data/frameworks/sproutcore/frameworks/desktop/tests/panes/{dropDown → select_button}/methods.js +15 -11
  67. data/frameworks/sproutcore/frameworks/desktop/tests/panes/{dropDown → select_button}/ui.js +22 -22
  68. data/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +1 -1
  69. data/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +0 -1
  70. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/deleteSelection.js +1 -1
  71. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/deselect.js +19 -3
  72. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/itemViewForContentIndex.js +1 -1
  73. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +53 -28
  74. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/select.js +6 -6
  75. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectNextItem.js +23 -9
  76. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectPreviousItem.js +24 -10
  77. data/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowHeightForContentIndex.js +1 -1
  78. data/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +1 -1
  79. data/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +10 -3
  80. data/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +1 -1
  81. data/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +50 -28
  82. data/frameworks/sproutcore/frameworks/desktop/tests/views/scroller/methods.js +6 -6
  83. data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +3 -3
  84. data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +8 -8
  85. data/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +1 -1
  86. data/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +1 -1
  87. data/frameworks/sproutcore/frameworks/desktop/views/button.js +5 -3
  88. data/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +4 -3
  89. data/frameworks/sproutcore/frameworks/desktop/views/collection.js +125 -96
  90. data/frameworks/sproutcore/frameworks/desktop/views/grid.js +1 -0
  91. data/frameworks/sproutcore/frameworks/desktop/views/list.js +68 -18
  92. data/frameworks/sproutcore/frameworks/desktop/views/list_item.js +134 -56
  93. data/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +18 -11
  94. data/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +562 -2
  95. data/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +13 -0
  96. data/frameworks/sproutcore/frameworks/desktop/views/progress.js +11 -8
  97. data/frameworks/sproutcore/frameworks/desktop/views/radio.js +7 -7
  98. data/frameworks/sproutcore/frameworks/desktop/views/scroll.js +99 -33
  99. data/frameworks/sproutcore/frameworks/desktop/views/scroller.js +3 -7
  100. data/frameworks/sproutcore/frameworks/desktop/views/segmented.js +0 -7
  101. data/frameworks/sproutcore/frameworks/desktop/views/separator.js +2 -3
  102. data/frameworks/sproutcore/frameworks/desktop/views/slider.js +0 -8
  103. data/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +1 -1
  104. data/frameworks/sproutcore/frameworks/desktop/views/split.js +27 -7
  105. data/frameworks/sproutcore/frameworks/desktop/views/tab.js +2 -6
  106. data/frameworks/sproutcore/frameworks/foundation/controllers/array.js +15 -10
  107. data/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +20 -1
  108. data/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +1 -1
  109. data/frameworks/sproutcore/frameworks/foundation/english.lproj/bootstrap.rhtml +3 -6
  110. data/frameworks/sproutcore/frameworks/foundation/english.lproj/button_view.css +3 -0
  111. data/frameworks/sproutcore/frameworks/foundation/english.lproj/core.css +8 -0
  112. data/frameworks/sproutcore/frameworks/foundation/english.lproj/inline_editor.css +12 -0
  113. data/frameworks/sproutcore/frameworks/foundation/english.lproj/label.css +11 -0
  114. data/frameworks/sproutcore/frameworks/foundation/english.lproj/text_field.css +13 -0
  115. data/frameworks/sproutcore/frameworks/foundation/mixins/button.js +1 -2
  116. data/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +70 -21
  117. data/frameworks/sproutcore/frameworks/foundation/mixins/selection_support.js +88 -54
  118. data/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +0 -25
  119. data/frameworks/sproutcore/frameworks/foundation/mixins/string.js +23 -2
  120. data/frameworks/sproutcore/frameworks/foundation/panes/pane.js +34 -23
  121. data/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +20 -0
  122. data/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +32 -23
  123. data/frameworks/sproutcore/frameworks/foundation/system/browser.js +2 -2
  124. data/frameworks/sproutcore/frameworks/foundation/system/bundle.js +77 -15
  125. data/frameworks/sproutcore/frameworks/foundation/system/core_query.js +5 -4
  126. data/frameworks/sproutcore/frameworks/foundation/system/cursor.js +1 -1
  127. data/frameworks/sproutcore/frameworks/foundation/system/render_context.js +22 -7
  128. data/frameworks/sproutcore/frameworks/foundation/system/request.js +466 -309
  129. data/frameworks/sproutcore/frameworks/foundation/system/responder.js +2 -1
  130. data/frameworks/sproutcore/frameworks/foundation/system/response.js +457 -0
  131. data/frameworks/sproutcore/frameworks/foundation/system/root_responder.js +66 -15
  132. data/frameworks/sproutcore/frameworks/foundation/system/routes.js +4 -4
  133. data/frameworks/sproutcore/frameworks/foundation/system/timer.js +6 -4
  134. data/frameworks/sproutcore/frameworks/foundation/system/utils.js +46 -8
  135. data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/array_case.js +17 -0
  136. data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/enum_case.js +18 -5
  137. data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/null_case.js +1 -1
  138. data/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +0 -2
  139. data/frameworks/sproutcore/frameworks/foundation/tests/mixins/string.js +11 -0
  140. data/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/group_case.js +14 -14
  141. data/frameworks/sproutcore/frameworks/foundation/tests/system/builder.js +2 -2
  142. data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_core.js +15 -3
  143. data/frameworks/sproutcore/frameworks/foundation/tests/system/datetime.js +1 -1
  144. data/frameworks/sproutcore/frameworks/foundation/tests/system/locale.js +8 -7
  145. data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/tag.js +3 -2
  146. data/frameworks/sproutcore/frameworks/foundation/tests/system/request.js +51 -44
  147. data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/targetForAction.js +2 -2
  148. data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/isPaused.js +4 -4
  149. data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js +2 -0
  150. data/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js +9 -9
  151. data/frameworks/sproutcore/frameworks/foundation/tests/validators/number.js +2 -2
  152. data/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +3 -3
  153. data/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +10 -3
  154. data/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +2 -2
  155. data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/append_remove.js +14 -0
  156. data/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +5 -5
  157. data/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +1 -11
  158. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/clippingFrame.js +2 -2
  159. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/destroyLayer.js +2 -4
  160. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/findLayerInParentLayer.js +2 -4
  161. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/insertBefore.js +1 -1
  162. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layoutStyle.js +0 -2
  163. data/frameworks/sproutcore/frameworks/foundation/validators/password.js +5 -5
  164. data/frameworks/sproutcore/frameworks/foundation/validators/validator.js +4 -2
  165. data/frameworks/sproutcore/frameworks/foundation/views/field.js +5 -8
  166. data/frameworks/sproutcore/frameworks/foundation/views/label.js +21 -5
  167. data/frameworks/sproutcore/frameworks/foundation/views/text_field.js +112 -69
  168. data/frameworks/sproutcore/frameworks/foundation/views/view.js +67 -6
  169. data/frameworks/sproutcore/frameworks/runtime/core.js +51 -2
  170. data/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +4 -1
  171. data/frameworks/sproutcore/frameworks/runtime/system/binding.js +2 -1
  172. data/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +5 -4
  173. data/frameworks/sproutcore/frameworks/runtime/system/index_set.js +6 -1
  174. data/frameworks/sproutcore/frameworks/runtime/system/logger.js +408 -0
  175. data/frameworks/sproutcore/frameworks/runtime/system/object.js +15 -4
  176. data/frameworks/sproutcore/frameworks/runtime/system/selection_set.js +30 -2
  177. data/frameworks/sproutcore/frameworks/runtime/tests/core/IsEqual.js +5 -1
  178. data/frameworks/sproutcore/frameworks/runtime/tests/core/beget.js +1 -1
  179. data/frameworks/sproutcore/frameworks/runtime/tests/core/compare.js +3 -3
  180. data/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +2 -0
  181. data/frameworks/sproutcore/frameworks/runtime/tests/core/isArray.js +1 -1
  182. data/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +2 -1
  183. data/frameworks/sproutcore/frameworks/runtime/tests/core/tupleForPropertyPath.js +2 -2
  184. data/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +1 -1
  185. data/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +1 -0
  186. data/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +11 -7
  187. data/frameworks/sproutcore/frameworks/runtime/tests/system/error.js +3 -2
  188. data/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/add.js +18 -1
  189. data/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/remove.js +1 -1
  190. data/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +165 -0
  191. data/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +3 -0
  192. data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/copy.js +1 -1
  193. data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/indexSetForSource.js +13 -0
  194. data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/remove.js +24 -0
  195. data/frameworks/sproutcore/frameworks/runtime/tests/system/sparse_array.js +32 -13
  196. data/frameworks/sproutcore/frameworks/testing/english.lproj/runner.css +2 -2
  197. data/frameworks/sproutcore/frameworks/testing/english.lproj/testsuite.css +7 -2
  198. data/frameworks/sproutcore/lib/index.rhtml +6 -20
  199. data/frameworks/sproutcore/themes/standard_theme/Source/sc-theme-repeat-x.psd +0 -0
  200. data/frameworks/sproutcore/themes/standard_theme/english.lproj/button.css +0 -1
  201. data/frameworks/sproutcore/themes/standard_theme/english.lproj/checkbox.css +5 -4
  202. data/frameworks/sproutcore/themes/standard_theme/english.lproj/collection.css +4 -3
  203. data/frameworks/sproutcore/themes/standard_theme/english.lproj/disclosure.css +7 -7
  204. data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-repeat-x.png +0 -0
  205. data/frameworks/sproutcore/themes/standard_theme/english.lproj/list_item.css +38 -0
  206. data/frameworks/sproutcore/themes/standard_theme/english.lproj/menu.css +20 -0
  207. data/frameworks/sproutcore/themes/standard_theme/english.lproj/progress.css +1 -0
  208. data/frameworks/sproutcore/themes/standard_theme/english.lproj/radio.css +3 -1
  209. data/frameworks/sproutcore/themes/standard_theme/english.lproj/segmented.css +1 -0
  210. data/frameworks/sproutcore/themes/standard_theme/english.lproj/split_view.css +1 -1
  211. data/frameworks/sproutcore/themes/standard_theme/english.lproj/text_field.css +0 -15
  212. data/gen/data-source/Buildfile +18 -0
  213. data/gen/data-source/README +1 -0
  214. data/gen/data-source/USAGE +15 -0
  215. data/gen/data-source/templates/data_sources/@filename@.js +64 -0
  216. data/lib/sproutcore/builders/combine.rb +23 -0
  217. data/lib/sproutcore/builders/javascript.rb +27 -2
  218. data/lib/sproutcore/buildfile/task.rb +1 -1
  219. data/lib/sproutcore/helpers/entry_sorter.rb +2 -2
  220. data/lib/sproutcore/helpers/static_helper.rb +79 -0
  221. data/lib/sproutcore/models/manifest.rb +2 -2
  222. data/lib/sproutcore/models/target.rb +1 -1
  223. data/lib/sproutcore/tools/build.rb +1 -1
  224. data/lib/sproutcore/tools/docs.rb +3 -3
  225. data/lib/sproutcore/tools/gen.rb +17 -15
  226. data/lib/sproutcore/tools/manifest.rb +9 -9
  227. data/lib/sproutcore/tools/server.rb +3 -3
  228. data/lib/sproutcore/tools.rb +259 -250
  229. data/lib/sproutcore.rb +9 -1
  230. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +2 -2
  231. data/spec/fixtures/entry_for_project/frameworks/unrelated/PLACEHOLDER +0 -0
  232. data/spec/fixtures/ordered_entries/apps/no_requires/{lproj → english.lproj}/strings.js +0 -0
  233. data/spec/fixtures/ordered_entries/apps/no_requires/main.js +1 -0
  234. data/spec/fixtures/ordered_entries/apps/no_requires/resources/main_page.js +1 -0
  235. data/spec/fixtures/ordered_entries/apps/no_requires/t.js +1 -0
  236. data/spec/lib/models/manifest/find_entry.rb +12 -0
  237. data/spec/lib/tools/gen_spec.rb +1 -0
  238. data/spec/lib/tools/tools_spec.rb +1 -0
  239. data/sproutcore-abbot.gemspec +36 -44
  240. metadata +43 -44
  241. data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/indicator.gif +0 -0
  242. data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sc-theme-sprite.png +0 -0
  243. data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sticky-note.png +0 -0
  244. data/frameworks/sproutcore/frameworks/desktop/views/form.js +0 -594
  245. data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-sprite.png +0 -0
  246. data/lib/thor/CHANGELOG.rdoc +0 -52
  247. data/lib/thor/LICENSE +0 -20
  248. data/lib/thor/README.markdown +0 -76
  249. data/lib/thor/Rakefile +0 -6
  250. data/lib/thor/Thorfile +0 -45
  251. data/lib/thor/bin/rake2thor +0 -83
  252. data/lib/thor/bin/thor +0 -7
  253. data/lib/thor/lib/thor/error.rb +0 -3
  254. data/lib/thor/lib/thor/options.rb +0 -267
  255. data/lib/thor/lib/thor/ordered_hash.rb +0 -64
  256. data/lib/thor/lib/thor/runner.rb +0 -305
  257. data/lib/thor/lib/thor/task.rb +0 -83
  258. data/lib/thor/lib/thor/task_hash.rb +0 -22
  259. data/lib/thor/lib/thor/tasks/package.rb +0 -18
  260. data/lib/thor/lib/thor/tasks.rb +0 -77
  261. data/lib/thor/lib/thor/util.rb +0 -75
  262. data/lib/thor/lib/thor.rb +0 -170
  263. data/lib/thor/script/destroy +0 -14
  264. data/lib/thor/script/generate +0 -14
  265. data/lib/thor/spec/fixtures/task.thor +0 -10
  266. data/lib/thor/spec/options_spec.rb +0 -271
  267. data/lib/thor/spec/ordered_hash_spec.rb +0 -84
  268. data/lib/thor/spec/spec.opts +0 -1
  269. data/lib/thor/spec/spec_helper.rb +0 -30
  270. data/lib/thor/spec/task_spec.rb +0 -11
  271. data/lib/thor/spec/tasks_spec.rb +0 -28
  272. data/lib/thor/spec/thor_runner_spec.rb +0 -194
  273. data/lib/thor/spec/thor_spec.rb +0 -206
  274. data/lib/thor/spec/util_spec.rb +0 -99
  275. data/lib/thor/task.thor +0 -15
  276. data/lib/thor/thor.gemspec +0 -29
@@ -27,6 +27,14 @@ sc_require('models/record');
27
27
  @since SproutCore 1.0
28
28
  */
29
29
  SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
30
+
31
+ /**
32
+ An (optional) name of the store, which can be useful during debugging,
33
+ especially if you have multiple nested stores.
34
+
35
+ @property {String}
36
+ */
37
+ name: null,
30
38
 
31
39
  /**
32
40
  An array of all the chained stores that current rely on the receiver
@@ -123,13 +131,23 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
123
131
  }}}
124
132
 
125
133
  @param {Hash} attrs optional attributes to set on new store
134
+ @param {Class} newStoreClass optional the class of the newly-created nested store (defaults to SC.NestedStore)
126
135
  @returns {SC.NestedStore} new nested store chained to receiver
127
136
  */
128
- chain: function(attrs) {
137
+ chain: function(attrs, newStoreClass) {
129
138
  if (!attrs) attrs = {};
130
139
  attrs.parentStore = this;
131
140
 
132
- var ret = SC.NestedStore.create(attrs),
141
+ if (newStoreClass) {
142
+ // Ensure the passed-in class is a type of nested store.
143
+ if (SC.typeOf(newStoreClass) !== 'class') throw new Error("%@ is not a valid class".fmt(newStoreClass));
144
+ if (!SC.kindOf(newStoreClass, SC.NestedStore)) throw new Error("%@ is not a type of SC.NestedStore".fmt(newStoreClass));
145
+ }
146
+ else {
147
+ newStoreClass = SC.NestedStore;
148
+ }
149
+
150
+ var ret = newStoreClass.create(attrs),
133
151
  nested = this.nestedStores;
134
152
 
135
153
  if (!nested) nested = this.nestedStores = [];
@@ -234,6 +252,28 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
234
252
  */
235
253
  recordArraysWithQuery: null,
236
254
 
255
+ /**
256
+ An array of SC.Error objects associated with individual records in the
257
+ store (indexed by store keys).
258
+
259
+ Errors passed form the data source in the call to dataSourceDidError() are
260
+ stored here.
261
+
262
+ @property {Array}
263
+ */
264
+ recordErrors: null,
265
+
266
+ /**
267
+ A hash of SC.Error objects associated with queries (indexed by the GUID
268
+ of the query).
269
+
270
+ Errors passed from the data source in the call to dataSourceDidErrorQuery()
271
+ are stored here.
272
+
273
+ @property {Hash}
274
+ */
275
+ queryErrors: null,
276
+
237
277
  // ..........................................................
238
278
  // CORE ATTRIBUTE API
239
279
  //
@@ -482,7 +522,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
482
522
  // when store needs to propagate out changes in the parent store
483
523
  // to nested stores
484
524
  if (editState === K.INHERITED) {
485
- store._notifyRecordPropertyChange(storeKey, statusOnly);
525
+ store._notifyRecordPropertyChange(storeKey, statusOnly, key);
486
526
 
487
527
  } else if (status & SC.Record.BUSY) {
488
528
  // make sure nested store does not have any changes before resetting
@@ -495,9 +535,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
495
535
  var changes = this.recordPropertyChanges;
496
536
  if (!changes) {
497
537
  changes = this.recordPropertyChanges =
498
- { storeKeys: SC.CoreSet.create(),
499
- records: SC.CoreSet.create(),
500
- statusOnly: SC.CoreSet.create(),
538
+ { storeKeys: SC.CoreSet.create(),
539
+ records: SC.CoreSet.create(),
540
+ hasDataChanges: SC.CoreSet.create(),
501
541
  propertyForStoreKeys: {} };
502
542
  }
503
543
 
@@ -505,15 +545,32 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
505
545
 
506
546
  if (records && (rec=records[storeKey])) {
507
547
  changes.records.push(storeKey);
508
- if(statusOnly) changes.statusOnly.push(storeKey);
509
548
 
510
- // if this is a key specific change, make sure that only those
511
- // properties/keys are notified
549
+ // If there are changes other than just the status we need to record
550
+ // that information so we do the right thing during the next flush.
551
+ // Note that if we're called multiple times before flush and one call
552
+ // has statusOnly=true and another has statusOnly=false, the flush will
553
+ // (correctly) operate in statusOnly=false mode.
554
+ if (!statusOnly) changes.hasDataChanges.push(storeKey);
555
+
556
+ // If this is a key specific change, make sure that only those
557
+ // properties/keys are notified. However, if a previous invocation of
558
+ // _notifyRecordPropertyChange specified that all keys have changed, we
559
+ // need to respect that.
512
560
  if (key) {
513
561
  if (!(keys = changes.propertyForStoreKeys[storeKey])) {
514
562
  keys = changes.propertyForStoreKeys[storeKey] = SC.CoreSet.create();
515
563
  }
516
- keys.add(key);
564
+
565
+ // If it's '*' instead of a set, then that means there was a previous
566
+ // invocation that said all keys have changed.
567
+ if (keys !== '*') {
568
+ keys.add(key);
569
+ }
570
+ }
571
+ else {
572
+ // Mark that all properties have changed.
573
+ changes.propertyForStoreKeys[storeKey] = '*';
517
574
  }
518
575
  }
519
576
 
@@ -532,25 +589,28 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
532
589
  flush: function() {
533
590
  if (!this.recordPropertyChanges) return this;
534
591
 
535
- var changes = this.recordPropertyChanges,
536
- storeKeys = changes.storeKeys,
537
- statusOnly = changes.statusOnly,
538
- records = changes.records,
539
- propertyForStoreKeys = changes.propertyForStoreKeys,
592
+ var changes = this.recordPropertyChanges,
593
+ storeKeys = changes.storeKeys,
594
+ hasDataChanges = changes.hasDataChanges,
595
+ records = changes.records,
596
+ propertyForStoreKeys = changes.propertyForStoreKeys,
540
597
  recordTypes = SC.CoreSet.create(),
541
- rec, recordType, status, idx, len, storeKey, keys;
598
+ rec, recordType, statusOnly, idx, len, storeKey, keys;
542
599
 
543
600
  storeKeys.forEach(function(storeKey) {
544
-
545
601
  if (records.contains(storeKey)) {
546
- status = statusOnly.contains(storeKey) ? YES: NO;
602
+ statusOnly = hasDataChanges.contains(storeKey) ? NO : YES;
547
603
  rec = this.records[storeKey];
548
604
  keys = propertyForStoreKeys ? propertyForStoreKeys[storeKey] : null;
549
605
 
606
+ // Are we invalidating all keys? If so, don't pass any to
607
+ // storeDidChangeProperties.
608
+ if (keys === '*') keys = null;
609
+
550
610
  // remove it so we don't trigger this twice
551
611
  records.remove(storeKey);
552
612
 
553
- if (rec) rec.storeDidChangeProperties(status, keys);
613
+ if (rec) rec.storeDidChangeProperties(statusOnly, keys);
554
614
  }
555
615
 
556
616
  recordType = SC.Store.recordTypeFor(storeKey);
@@ -561,9 +621,10 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
561
621
  this._notifyRecordArrays(storeKeys, recordTypes);
562
622
 
563
623
  storeKeys.clear();
564
- statusOnly.clear();
624
+ hasDataChanges.clear();
565
625
  records.clear();
566
- propertyForStoreKeys.length = 0; // reset
626
+ // Provide full reference to overwrite
627
+ this.recordPropertyChanges.propertyForStoreKeys = {};
567
628
 
568
629
  return this;
569
630
  },
@@ -582,9 +643,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
582
643
  this.revisions = {} ;
583
644
  this.statuses = {} ;
584
645
 
585
- // also reset temporary objects
646
+ // also reset temporary objects and errors
586
647
  this.chainedChanges = this.locks = this.editables = null;
587
648
  this.changelog = null ;
649
+ this.recordErrors = null;
650
+ this.queryErrors = null;
588
651
 
589
652
  var records = this.records, storeKey;
590
653
  if (records) {
@@ -758,14 +821,15 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
758
821
  @returns {SC.Record} record instance or null
759
822
  */
760
823
  find: function(recordType, id) {
824
+
761
825
  // if recordType is passed as string, find object
762
826
  if (SC.typeOf(recordType)===SC.T_STRING) {
763
827
  recordType = SC.objectForPropertyPath(recordType);
764
828
  }
765
829
 
766
830
  // handle passing a query...
767
- if ((arguments.length === 1) && !(recordType && recordType.isRecord)) {
768
- if (!recordType) throw "SC.Store#find() must pass recordType or query";
831
+ if ((arguments.length === 1) && !(recordType && recordType.get && recordType.get('isRecord'))) {
832
+ if (!recordType) throw new Error("SC.Store#find() must pass recordType or query");
769
833
  if (!recordType.isQuery) {
770
834
  recordType = SC.Query.local(recordType);
771
835
  }
@@ -882,7 +946,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
882
946
  @returns {SC.Store} receiver
883
947
  */
884
948
  refreshQuery: function(query) {
885
- if (!query) throw "refreshQuery() requires a query";
949
+ if (!query) throw new Error("refreshQuery() requires a query");
886
950
 
887
951
  var cache = this._scst_recordArraysByQuery,
888
952
  recArray = cache ? cache[SC.guidFor(query)] : null,
@@ -1676,6 +1740,30 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1676
1740
  // return storeKeys
1677
1741
  return ret ;
1678
1742
  },
1743
+
1744
+ /**
1745
+ Returns the SC.Error object associated with a specific record.
1746
+
1747
+ @param {Number} storeKey The store key of the record.
1748
+
1749
+ @returns {SC.Error} SC.Error or undefined if no error associated with the record.
1750
+ */
1751
+ readError: function(storeKey) {
1752
+ var errors = this.recordErrors ;
1753
+ return errors ? errors[storeKey] : undefined ;
1754
+ },
1755
+
1756
+ /**
1757
+ Returns the SC.Error object associated with a specific query.
1758
+
1759
+ @param {SC.Query} query The SC.Query with which the error is associated.
1760
+
1761
+ @returns {SC.Error} SC.Error or undefined if no error associated with the query.
1762
+ */
1763
+ readQueryError: function(query) {
1764
+ var errors = this.queryErrors ;
1765
+ return errors ? errors[SC.guidFor(query)] : undefined ;
1766
+ },
1679
1767
 
1680
1768
  // ..........................................................
1681
1769
  // DATA SOURCE CALLBACKS
@@ -1797,11 +1885,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1797
1885
  /**
1798
1886
  Converts the passed record into an error object.
1799
1887
 
1800
- @param {Number} storeKey record store key to cancel
1888
+ @param {Number} storeKey record store key to error
1889
+ @param {SC.Error} error [optional] an SC.Error instance to associate with storeKey
1801
1890
  @returns {SC.Store} reciever
1802
1891
  */
1803
1892
  dataSourceDidError: function(storeKey, error) {
1804
- var status = this.readStatus(storeKey), K = SC.Record;
1893
+ var status = this.readStatus(storeKey), errors = this.recordErrors, K = SC.Record;
1805
1894
 
1806
1895
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
1807
1896
  // DESTROYED_DIRTY
@@ -1810,6 +1899,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1810
1899
  // otherwise, determine proper state transition
1811
1900
  else status = K.ERROR ;
1812
1901
 
1902
+ // Add the error to the array of record errors (for lookup later on if necessary).
1903
+ if (error && error.isError) {
1904
+ if (!errors) errors = this.recordErrors = [];
1905
+ errors[storeKey] = error;
1906
+ }
1907
+
1813
1908
  this.writeStatus(storeKey, status) ;
1814
1909
  this.dataHashDidChange(storeKey, null, YES);
1815
1910
 
@@ -1881,17 +1976,25 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1881
1976
 
1882
1977
  @param {Class} recordType the SC.Record subclass
1883
1978
  @param {Object} id the record id or null
1884
- @param {Number} storeKey optional store key.
1979
+ @param {SC.Error} error [optional] an SC.Error instance to associate with id or storeKey
1980
+ @param {Number} storeKey optional store key.
1885
1981
  @returns {Boolean} YES if push was allowed
1886
1982
  */
1887
1983
  pushError: function(recordType, id, error, storeKey) {
1888
- var K = SC.Record, status;
1984
+ var K = SC.Record, status, errors = this.recordErrors;
1889
1985
 
1890
1986
  if(storeKey===undefined) storeKey = recordType.storeKeyFor(id);
1891
1987
  status = this.readStatus(storeKey);
1892
1988
 
1893
1989
  if(status==K.EMPTY || status==K.ERROR || status==K.READY_CLEAN || status==K.DESTROY_CLEAN){
1894
1990
  status = K.ERROR;
1991
+
1992
+ // Add the error to the array of record errors (for lookup later on if necessary).
1993
+ if (error && error.isError) {
1994
+ if (!errors) errors = this.recordErrors = [];
1995
+ errors[storeKey] = error;
1996
+ }
1997
+
1895
1998
  this.writeStatus(storeKey, status) ;
1896
1999
  this.dataHashDidChange(storeKey, null, YES);
1897
2000
  return YES;
@@ -1928,7 +2031,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1928
2031
  */
1929
2032
  loadQueryResults: function(query, storeKeys) {
1930
2033
  if (query.get('location') === SC.Query.LOCAL) {
1931
- throw "Cannot load query results for a local query";
2034
+ throw new Error("Cannot load query results for a local query");
1932
2035
  }
1933
2036
 
1934
2037
  var recArray = this._findQuery(query, YES, NO);
@@ -2004,10 +2107,18 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2004
2107
  again.
2005
2108
 
2006
2109
  @param {SC.Query} query the query with the error
2007
- @param {SC.Error} error optional error object to set
2110
+ @param {SC.Error} error [optional] an SC.Error instance to associate with query
2008
2111
  @returns {SC.Store} receiver
2009
2112
  */
2010
2113
  dataSourceDidErrorQuery: function(query, error) {
2114
+ var errors = this.queryErrors;
2115
+
2116
+ // Add the error to the array of query errors (for lookup later on if necessary).
2117
+ if (error && error.isError) {
2118
+ if (!errors) errors = this.queryErrors = {};
2119
+ errors[SC.guidFor(query)] = error;
2120
+ }
2121
+
2011
2122
  return this._scstore_dataSourceDidErrorQuery(query, YES);
2012
2123
  },
2013
2124
 
@@ -2036,6 +2147,19 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2036
2147
  sc_super();
2037
2148
  this.reset();
2038
2149
  },
2150
+
2151
+
2152
+ toString: function() {
2153
+ // Include the name if the client has specified one.
2154
+ var name = this.get('name');
2155
+ if (!name) {
2156
+ return sc_super();
2157
+ }
2158
+ else {
2159
+ var ret = sc_super();
2160
+ return "%@ (%@)".fmt(name, ret);
2161
+ }
2162
+ },
2039
2163
 
2040
2164
 
2041
2165
  // ..........................................................
@@ -2170,6 +2294,14 @@ SC.Store.mixin({
2170
2294
  @property {Error}
2171
2295
  */
2172
2296
  NESTED_STORE_UNSUPPORTED_ERROR: new Error("Unsupported In Nested Store"),
2297
+
2298
+ /**
2299
+ Standard error if you try to retrieve a record in a nested store that is
2300
+ dirty. (This is allowed on the main store, but not in nested stores.)
2301
+
2302
+ @property {Error}
2303
+ */
2304
+ NESTED_STORE_RETRIEVE_DIRTY_ERROR: new Error("Cannot Retrieve Dirty Record in Nested Store"),
2173
2305
 
2174
2306
  /**
2175
2307
  Data hash state indicates the data hash is currently editable
@@ -2283,7 +2415,7 @@ SC.Store.mixin({
2283
2415
 
2284
2416
  recordType = this.recordTypeFor(storeKey);
2285
2417
  if (!recordType) {
2286
- throw "replaceIdFor: storeKey %@ does not exist".fmt(storeKey);
2418
+ throw new Error("replaceIdFor: storeKey %@ does not exist".fmt(storeKey));
2287
2419
  }
2288
2420
 
2289
2421
  // map one direction...
@@ -6,7 +6,7 @@
6
6
  /*globals module ok equals same test MyApp */
7
7
 
8
8
  // test core array-mapping methods for ManyArray with ManyAttribute
9
- var storeKeys, rec;
9
+ var storeKeys, rec, rec2, rec3, rec4;
10
10
  var foo1, foo2, foo3, bar1, bar2, bar3;
11
11
 
12
12
  module("SC.ManyAttribute core methods", {
@@ -34,7 +34,12 @@ module("SC.ManyAttribute core methods", {
34
34
 
35
35
  // test toMany relationships
36
36
  fooMany: SC.Record.toMany('MyApp.Foo'),
37
-
37
+
38
+ // test toMany relationships with different key
39
+ fooManyKeyed: SC.Record.toMany('MyApp.Foo', {
40
+ key: 'fooIds'
41
+ }),
42
+
38
43
  // test many-to-many relationships with inverse
39
44
  barToMany: SC.Record.toMany('MyApp.Bar', {
40
45
  inverse: 'fooToMany', isMaster: YES, orderBy: 'name'
@@ -83,7 +88,11 @@ module("SC.ManyAttribute core methods", {
83
88
  barToOne: []
84
89
  },
85
90
 
86
- { guid: 4, firstName: "Johnny", lastName: "Cash" }
91
+ { guid: 4,
92
+ firstName: "Johnny",
93
+ lastName: "Cash",
94
+ fooIds: [1,2]
95
+ }
87
96
  ]);
88
97
 
89
98
  MyApp.store.loadRecords(MyApp.Bar, [
@@ -125,6 +134,13 @@ test("getting toMany relationship should map guid to real records", function() {
125
134
  equals(rec3.get('fooMany').objectAt(0), rec, 'should get rec1 instance for rec3.fooMany');
126
135
  equals(rec3.get('fooMany').objectAt(1), rec2, 'should get rec2 instance for rec3.fooMany');
127
136
  });
137
+
138
+ test("getting toMany relationship should map guid to real records when using different key", function() {
139
+ var rec4 = MyApp.store.find(MyApp.Foo, 4);
140
+ equals(rec4.get('id'), 4, 'precond - should find record 4');
141
+ equals(rec4.get('fooManyKeyed').objectAt(0), rec, 'should get rec1 instance for rec4.fooManyKeyed');
142
+ equals(rec4.get('fooManyKeyed').objectAt(1), rec2, 'should get rec2 instance for rec4.fooManyKeyed');
143
+ });
128
144
 
129
145
  test("getting toMany relation should not change record state", function() {
130
146
  equals(rec3.get('status'), SC.Record.READY_CLEAN, 'precond - status should be READY_CLEAN');
@@ -172,7 +188,19 @@ test("writing to a to-many relationship should update set guids", function() {
172
188
  SC.RunLoop.end();
173
189
 
174
190
  equals(rec3.get('fooMany').objectAt(0), rec2, 'should get rec2 instance for rec3.fooMany');
175
- equals(rec3.get('fooMany').objectAt(1), rec4, 'should get rec2 instance for rec3.fooMany');
191
+ equals(rec3.get('fooMany').objectAt(1), rec4, 'should get rec4 instance for rec3.fooMany');
192
+ });
193
+
194
+ test("writing to a to-many relationship should update set guids when using a different key", function() {
195
+ var rec4 = MyApp.store.find(MyApp.Foo, 4);
196
+ equals(rec4.get('id'), 4, 'precond - should find record 4');
197
+ equals(rec4.get('fooManyKeyed').objectAt(0), rec, 'should get rec1 instance for rec4.fooManyKeyed');
198
+
199
+ SC.RunLoop.begin();
200
+ rec4.set('fooManyKeyed', [rec2, rec3]);
201
+ SC.RunLoop.end();
202
+
203
+ ok(rec4.get('fooIds').isEqual([2,3]), 'should get array of guids (2, 3) for rec4.fooIds');
176
204
  });
177
205
 
178
206
  test("pushing an object to a to-many relationship attribute should update set guids", function() {
@@ -0,0 +1,56 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2009 Apple Inc. and contributors.
4
+ // License: Licened under MIT license (see license.js)
5
+ // ==========================================================================
6
+ /*globals module ok equals same test MyApp */
7
+
8
+ var store, Application;
9
+ module("SC.Record Error Methods", {
10
+ setup: function() {
11
+
12
+ Application = {};
13
+ Application.Thing = SC.Record.extend({
14
+ name: SC.Record.attr(String)
15
+ });
16
+
17
+ SC.RunLoop.begin();
18
+ store = SC.Store.create();
19
+
20
+ var records = [
21
+ { guid: 1, name: 'Thing One' },
22
+ { guid: 2, name: 'Thing Two' }
23
+ ];
24
+
25
+ var types = [ Application.Thing, Application.Thing ];
26
+
27
+ store.loadRecords(types, records);
28
+ SC.RunLoop.end();
29
+ },
30
+
31
+ teardown: function() {
32
+ store = null;
33
+ Application = null;
34
+ }
35
+ });
36
+
37
+ test("Verify error methods behave correctly", function() {
38
+ var thing1 = store.find(Application.Thing, 1);
39
+ var storeKey = thing1.get('storeKey');
40
+
41
+ var thing2 = store.find(Application.Thing, 2);
42
+
43
+ SC.RunLoop.begin();
44
+ store.writeStatus(storeKey, SC.Record.BUSY_LOADING);
45
+ store.dataSourceDidError(storeKey, SC.Record.GENERIC_ERROR);
46
+ SC.RunLoop.end();
47
+
48
+ ok(thing1.get('isError'), "isError on thing1 should be YES");
49
+ ok(!thing2.get('isError'), "isError on thing2 should be NO");
50
+
51
+ equals(thing1.get('errorObject'), SC.Record.GENERIC_ERROR,
52
+ "get('errorObject') on thing1 should return the correct error object");
53
+
54
+ equals(thing2.get('errorObject'), null,
55
+ "get('errorObject') on thing2 should return null");
56
+ });
@@ -6,7 +6,7 @@
6
6
  /*globals module ok equals same test MyApp */
7
7
 
8
8
  // test normalize method for SC.Record
9
- var storeKeys, rec;
9
+ var storeKeys, rec, rec2, rec3, rec4;
10
10
  module("SC.Record normalize method", {
11
11
  setup: function() {
12
12
 
@@ -22,6 +22,15 @@ module("SC.Record#unknownProperty", {
22
22
  };
23
23
 
24
24
  MyApp.foo = MyApp.store.createRecord(MyApp.Foo, MyApp.json);
25
+
26
+ MyApp.FooStrict = SC.Record.extend();
27
+
28
+ SC.mixin(MyApp.FooStrict, {
29
+ ignoreUnknownProperties: YES
30
+ });
31
+
32
+ MyApp.fooStrict = MyApp.store.createRecord(MyApp.FooStrict, MyApp.json);
33
+
25
34
  },
26
35
 
27
36
  teardown: function() {
@@ -49,3 +58,9 @@ test("set() should replace existing property", function() {
49
58
  equals(MyApp.store.dataHashes[MyApp.foo.storeKey].foo, 'baz', 'should update foo attribute');
50
59
  });
51
60
 
61
+ test("set() on unknown property if model ignoreUnknownProperties=YES should not write it to data hash", function() {
62
+ MyApp.fooStrict.set('foo', 'baz');
63
+ equals(MyApp.store.dataHashes[MyApp.fooStrict.storeKey].foo, 'bar', 'should not have written new value to dataHash');
64
+ });
65
+
66
+
@@ -68,7 +68,7 @@ test("raises exception if you try to write an attribute before an attribute hash
68
68
  store.removeDataHash(foo.storeKey);
69
69
  equals(store.readDataHash(foo.storeKey), null, 'precond - should not have store key');
70
70
 
71
- var e, cnt=0 ;
71
+ var cnt=0 ;
72
72
  try {
73
73
  foo.writeAttribute("foo", "bar");
74
74
  } catch(e) {
@@ -95,3 +95,18 @@ test("Writing to an attribute in chained store sets correct status", function()
95
95
 
96
96
  });
97
97
 
98
+
99
+ test("Writing a new guid", function(){
100
+ equals(foo.get('id'), 1, 'foo.id should be 1');
101
+ foo.set('guid', 2);
102
+ equals(foo.get('id'), 2, 'foo.id should be 2');
103
+ });
104
+
105
+ test("Writing primaryKey of 'id'", function(){
106
+ PrimaryKeyId = SC.Record.extend({ primaryKey: 'id' });
107
+ var foo2 = store.createRecord(PrimaryKeyId, { id: 1 });
108
+
109
+ equals(foo2.get('id'), 1, 'foo2.id should be 1');
110
+ foo2.set('id', 2);
111
+ equals(foo2.get('id'), 2, 'foo2.id should be 2');
112
+ });
@@ -6,7 +6,7 @@
6
6
  /*globals module ok equals same test MyApp */
7
7
 
8
8
  // test core array-mapping methods for RecordArray with RecordAttribute
9
- var storeKeys, rec, rec2, bar ;
9
+ var storeKeys, rec, rec2, bar, MyApp;
10
10
 
11
11
  module("SC.RecordAttribute core methods", {
12
12
  setup: function() {
@@ -27,7 +27,9 @@ module("SC.RecordAttribute core methods", {
27
27
  return (this.readAttribute('relatedToComputed').indexOf("foo")===0) ? MyApp.Foo : MyApp.Bar;
28
28
  }),
29
29
 
30
- bar: SC.Record.toOne('MyApp.Bar', { inverse: 'foo' })
30
+ bar: SC.Record.toOne('MyApp.Bar', { inverse: 'foo' }),
31
+
32
+ barKeyed: SC.Record.toOne('MyApp.Bar', { key: 'barId' })
31
33
 
32
34
  });
33
35
 
@@ -65,6 +67,13 @@ module("SC.RecordAttribute core methods", {
65
67
  anArray: ['one', 'two', 'three'],
66
68
  anObject: { 'key1': 'value1', 'key2': 'value2' },
67
69
  bar: "bar2"
70
+ },
71
+
72
+ {
73
+ guid: 'foo4',
74
+ firstName: 'Joe',
75
+ lastName: 'Schmo',
76
+ barId: 'bar1'
68
77
  }
69
78
 
70
79
  ]);
@@ -108,6 +117,11 @@ test("reading an inverse relationship", function() {
108
117
  equals(bar.get('foo'), rec, 'bar.foo should == foo1');
109
118
  });
110
119
 
120
+ test("reading a keyed relationship", function(){
121
+ var rec4 = MyApp.store.find(MyApp.Foo, 'foo4');
122
+ equals(rec4.get('barKeyed'), bar, 'foo4.barKeyed should == bar');
123
+ });
124
+
111
125
  // ..........................................................
112
126
  // WRITING
113
127
  //
@@ -214,3 +228,10 @@ test("modifying a toOne relationship with an inverse from other", function() {
214
228
 
215
229
  });
216
230
 
231
+ test("modifying a keyed toOne relationship", function(){
232
+ var rec4 = MyApp.store.find(MyApp.Foo, 'foo4');
233
+
234
+ rec4.set('barKeyed', bar2);
235
+
236
+ equals(rec4.get('barId'), 'bar2', 'foo4.barId should == bar2');
237
+ });
@@ -52,6 +52,37 @@ test("initial setup for chained store", function() {
52
52
  ok(!store.locks, 'should not have locks');
53
53
  ok(!store.chainedChanges, 'should not have chainedChanges');
54
54
  ok(!store.editables, 'should not have editables');
55
+ });
56
+
57
+ test("allow for custom subclasses of SC.NestedStore", function() {
58
+ var parent = SC.Store.create();
59
+
60
+ // We should get an exception if we specify a "subclass" that's not a class
61
+ var ex = null;
62
+ try {
63
+ var bogus = parent.chain({}, "I am not a class");
64
+ }
65
+ catch(e) {
66
+ ex = e;
67
+ }
68
+ ok(ex && ex.message && ex.message.indexOf('not a valid class') !== -1, 'chain should report that our bogus "class" it is not a valid class');
69
+
70
+ // We should get an exception if we specify a class that's not a subclass of
71
+ // SC.NestedStore
72
+ ex = null;
73
+ try {
74
+ var bogus = parent.chain({}, SC.Store);
75
+ }
76
+ catch(e) {
77
+ ex = e;
78
+ }
79
+ ok(ex && ex.message && ex.message.indexOf('is not a type of SC.NestedStore') !== -1, 'chain should report that our class needs to be a subclass of SC.NestedStore');
80
+
81
+
82
+ // Our specified (proper!) subclass should be respected.
83
+ var MyNestedStoreSubclass = SC.NestedStore.extend();
84
+ var nested = parent.chain({}, MyNestedStoreSubclass);
85
+ ok(nested.kindOf(MyNestedStoreSubclass), 'our nested store should be the SC.NestedStore subclass we specified');
55
86
  });
56
87
 
57
88
 
@@ -59,7 +90,7 @@ test("initial setup for chained store", function() {
59
90
  // SPECIAL CASES
60
91
  //
61
92
 
62
- test("chained store changes should propogate reliably", function() {
93
+ test("chained store changes should propagate reliably", function() {
63
94
  var parent = SC.Store.create(), rec, store, rec2;
64
95
 
65
96
  SC.run(function() {