sproutcore 1.6.0.rc.2-x86-mingw32 → 1.6.0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +12 -0
- data/VERSION.yml +1 -1
- data/bin/sc-docs +6 -1
- data/lib/buildtasks/target.rake +1 -1
- data/lib/frameworks/sproutcore/Buildfile +5 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +175 -1
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/select.js +12 -0
- data/lib/frameworks/sproutcore/apps/test_controls/resources/select_page.js +19 -5
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +28 -31
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +21 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/checkbox_support.js +6 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +26 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +12 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +25 -9
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +157 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +7 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +8 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +104 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/theme.js +3 -56
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +59 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +41 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/template_helpers/text_field_support.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +18 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/insertBefore.js +10 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +9 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +15 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +14 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +8 -18
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +296 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +330 -326
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +22 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +614 -614
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/data_source.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js +20 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +61 -46
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +30 -30
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/connectDataSource.js +31 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +1177 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +4 -63
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +7 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/checkbox.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/master_detail.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/menu.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/picker.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio_group.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/toolbar.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/well.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/workspace.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/segmented.css +1 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +33 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +20 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +34 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +14 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +40 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +699 -700
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +11 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +16 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +49 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +4 -26
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +20 -19
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +249 -249
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/edit_mode.js +13 -5
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/emptiness.js +53 -37
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form_row.js +3 -11
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/edit_mode.js +53 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/emptiness.js +114 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form.js +174 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_row.js +86 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +80 -110
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +96 -97
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +20 -36
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +121 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +90 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +139 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/render_delegates/select_button.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +25 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +43 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +32 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/menu_setup.js +40 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/show_menu.js +45 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/menu_width.js +49 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +191 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +264 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +450 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split_divider.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/thumb.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -17
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +35 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/images/favicon.ico +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/system/exception_handler.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/system/math.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +6 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +912 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +36 -7
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +58 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +25 -14
- data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/flatten.js +24 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/range_observer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +15 -16
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +30 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/range_observer/create.js +17 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/testing/resources/runner.css +0 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +80 -0
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/core.css +0 -4
- data/lib/frameworks/sproutcore/lib/index.rhtml +2 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +3 -3
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/form/form.css +9 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +3 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/picker.js +1 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/workspace.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/button.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/panel.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/progress.js +2 -0
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/slider.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/well.js +1 -1
- data/lib/sproutcore/builders/base.rb +5 -1
- data/lib/sproutcore/builders/handlebars.rb +12 -1
- data/lib/sproutcore/models/target.rb +1 -9
- data/lib/sproutcore/rack/proxy.rb +238 -92
- data/lib/sproutcore/tools/docs.rb +1 -7
- data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -0
- data/spec/fixtures/builder_tests/apps/handlebars_test/{template.handlebars → templates/template.handlebars} +2 -0
- data/spec/lib/builders/handlebars_spec.rb +10 -4
- data/sproutcore.gemspec +3 -1
- metadata +73 -44
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/default_styles.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/strings.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_checkbox_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_label.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_radio_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_text_field.js +0 -17
@@ -5,7 +5,7 @@
|
|
5
5
|
// ==========================================================================
|
6
6
|
/*globals JN module test ok equals same stop start */
|
7
7
|
|
8
|
-
var MyApp, wasCalled;
|
8
|
+
var MyApp, wasCalled, resetWasCalled;
|
9
9
|
module("SC.DataSource", {
|
10
10
|
setup: function () {
|
11
11
|
MyApp = window.MyApp = {};
|
@@ -41,6 +41,11 @@ module("SC.DataSource", {
|
|
41
41
|
wasCalled = true;
|
42
42
|
equals(arguments.length, 3);
|
43
43
|
return YES;
|
44
|
+
},
|
45
|
+
|
46
|
+
reset: function() {
|
47
|
+
resetWasCalled = true;
|
48
|
+
return this;
|
44
49
|
}
|
45
50
|
});
|
46
51
|
SC.RunLoop.begin();
|
@@ -188,3 +193,11 @@ test("The dataSource will return NO when all records committed return NO", funct
|
|
188
193
|
equals(MyApp.store.commitRecords(), NO,
|
189
194
|
"commiting records for an 'update', 'create', and 'destroy' should return NO");
|
190
195
|
});
|
196
|
+
|
197
|
+
test("The store calls reset on the dataSource when reset", function(){
|
198
|
+
MyApp.store.set('dataSource', MyApp.DataSource.create());
|
199
|
+
resetWasCalled = NO; // Just to be sure
|
200
|
+
|
201
|
+
MyApp.store.reset();
|
202
|
+
ok(resetWasCalled, "should have called reset");
|
203
|
+
});
|
data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
//
|
10
10
|
var NestedRecord, store, testParent, testParent2, childData1;
|
11
11
|
|
12
|
-
var initModels = function(){
|
12
|
+
var initModels = function() {
|
13
13
|
NestedRecord.ParentRecordTest = SC.Record.extend({
|
14
14
|
/** Child Record Namespace */
|
15
15
|
nestedRecordNamespace: NestedRecord,
|
@@ -34,6 +34,7 @@ module("Basic SC.Record Functions w/ Parent > Child", {
|
|
34
34
|
NestedRecord = SC.Object.create({
|
35
35
|
store: SC.Store.create()
|
36
36
|
});
|
37
|
+
window.NestedRecord = NestedRecord;
|
37
38
|
store = NestedRecord.store;
|
38
39
|
initModels();
|
39
40
|
SC.RunLoop.begin();
|
@@ -79,6 +80,7 @@ module("Basic SC.Record Functions w/ Parent > Child", {
|
|
79
80
|
store = null;
|
80
81
|
childData1 = null;
|
81
82
|
NestedRecord = null;
|
83
|
+
delete(window.NestedRecord);
|
82
84
|
}
|
83
85
|
});
|
84
86
|
|
@@ -42,6 +42,7 @@ module("Complex SC.Record: Parent > Array of Children > Array of Children", {
|
|
42
42
|
NestedRecord = SC.Object.create({
|
43
43
|
store: SC.Store.create()
|
44
44
|
});
|
45
|
+
window.NestedRecord = NestedRecord;
|
45
46
|
store = NestedRecord.store;
|
46
47
|
initModels();
|
47
48
|
SC.RunLoop.begin();
|
@@ -117,6 +118,7 @@ module("Complex SC.Record: Parent > Array of Children > Array of Children", {
|
|
117
118
|
delete NestedRecord.Group;
|
118
119
|
delete NestedRecord.Person;
|
119
120
|
delete NestedRecord.Address;
|
121
|
+
delete window.NestedRecord;
|
120
122
|
NestedRecord = null;
|
121
123
|
testParent = null;
|
122
124
|
peopleData1 = null;
|
@@ -42,6 +42,7 @@ module("Basic SC.Record Functions w/ a Parent > Child > Child", {
|
|
42
42
|
NestedRecord = SC.Object.create({
|
43
43
|
store: SC.Store.create()
|
44
44
|
});
|
45
|
+
window.NestedRecord = NestedRecord;
|
45
46
|
store = NestedRecord.store;
|
46
47
|
initModels();
|
47
48
|
SC.RunLoop.begin();
|
@@ -65,6 +66,7 @@ module("Basic SC.Record Functions w/ a Parent > Child > Child", {
|
|
65
66
|
delete NestedRecord.ParentRecordTest;
|
66
67
|
delete NestedRecord.Person;
|
67
68
|
delete NestedRecord.Address;
|
69
|
+
delete window.NestedRecord;
|
68
70
|
NestedRecord = null;
|
69
71
|
testParent = null;
|
70
72
|
store = null;
|
@@ -8,33 +8,33 @@
|
|
8
8
|
var MyApp, dataSource;
|
9
9
|
module("SC.Record core methods", {
|
10
10
|
setup: function() {
|
11
|
-
dataSource = SC.DataSource.create({
|
12
|
-
|
11
|
+
dataSource = SC.DataSource.create({
|
12
|
+
|
13
13
|
gotParams: NO,
|
14
14
|
wasCommitted: NO,
|
15
|
-
|
15
|
+
|
16
16
|
createRecord: function(store, storeKey, params) {
|
17
17
|
this.wasCommitted = YES;
|
18
18
|
this.gotParams = params && params['param1'] ? YES: NO;
|
19
19
|
}});
|
20
|
-
|
20
|
+
|
21
21
|
MyApp = SC.Object.create({
|
22
22
|
store: SC.Store.create().from(dataSource)
|
23
23
|
}) ;
|
24
|
-
|
24
|
+
|
25
25
|
MyApp.Foo = SC.Record.extend({});
|
26
|
-
MyApp.json = {
|
27
|
-
foo: "bar",
|
26
|
+
MyApp.json = {
|
27
|
+
foo: "bar",
|
28
28
|
number: 123,
|
29
29
|
bool: YES,
|
30
30
|
array: [1,2,3],
|
31
31
|
guid: 1
|
32
32
|
};
|
33
|
-
|
33
|
+
|
34
34
|
SC.RunLoop.begin();
|
35
35
|
MyApp.foo = MyApp.store.createRecord(MyApp.Foo, MyApp.json);
|
36
36
|
SC.RunLoop.end();
|
37
|
-
|
37
|
+
|
38
38
|
}
|
39
39
|
});
|
40
40
|
|
@@ -43,13 +43,20 @@ test("statusString", function() {
|
|
43
43
|
});
|
44
44
|
|
45
45
|
test("Can commitRecord() specific SC.Record instance", function() {
|
46
|
-
|
46
|
+
|
47
47
|
MyApp.foo.set('foo', 'foobar');
|
48
|
-
|
48
|
+
|
49
49
|
// commit the new record
|
50
50
|
MyApp.foo.commitRecord({ param1: 'value1' });
|
51
|
-
|
51
|
+
|
52
52
|
equals(dataSource.wasCommitted, YES, 'Record was committed');
|
53
53
|
equals(dataSource.gotParams, YES, 'Params were properly passed through commitRecord');
|
54
|
-
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
test("JSON encoding an SC.Record should encode the attributes", function(){
|
58
|
+
var str = SC.json.encode(MyApp.foo);
|
59
|
+
var result = SC.json.decode(str);
|
60
|
+
|
61
|
+
same(MyApp.json, result, "original = encoded record");
|
55
62
|
});
|
@@ -14,72 +14,72 @@ module("SC.RecordAttribute core methods", {
|
|
14
14
|
MyApp = SC.Object.create({
|
15
15
|
store: SC.Store.create()
|
16
16
|
});
|
17
|
-
|
17
|
+
|
18
18
|
// stick it to the window object so that objectForPropertyPath works
|
19
19
|
window.MyApp = MyApp;
|
20
|
-
|
20
|
+
|
21
21
|
MyApp.Foo = SC.Record.extend({
|
22
|
-
|
22
|
+
|
23
23
|
// test simple reading of a pass-through prop
|
24
24
|
firstName: SC.Record.attr(String),
|
25
25
|
|
26
26
|
// test mapping to another internal key
|
27
27
|
otherName: SC.Record.attr(String, { key: "firstName" }),
|
28
|
-
|
28
|
+
|
29
29
|
// test mapping Date
|
30
30
|
date: SC.Record.attr(Date),
|
31
31
|
nonIsoDate: SC.Record.attr(Date, { useIsoDate: false }),
|
32
32
|
|
33
33
|
// test SC.DateTimes
|
34
34
|
dateTime: SC.Record.attr(SC.DateTime),
|
35
|
-
|
35
|
+
|
36
36
|
// test Array
|
37
37
|
anArray: SC.Record.attr(Array),
|
38
|
-
|
38
|
+
|
39
39
|
// test Object
|
40
40
|
anObject: SC.Record.attr(Object),
|
41
|
-
|
41
|
+
|
42
42
|
// test Number
|
43
43
|
aNumber: SC.Record.attr(Number),
|
44
|
-
|
44
|
+
|
45
45
|
// used to test default value
|
46
46
|
defaultValue: SC.Record.attr(String, {
|
47
47
|
defaultValue: "default"
|
48
48
|
}),
|
49
|
-
|
49
|
+
|
50
50
|
// used to test default value
|
51
51
|
defaultComputedValue: SC.Record.attr(Number, {
|
52
52
|
defaultValue: function() {
|
53
53
|
return Math.floor(Math.random()*3+1);
|
54
54
|
}
|
55
55
|
}),
|
56
|
-
|
56
|
+
|
57
57
|
// test toOne relationships
|
58
58
|
relatedTo: SC.Record.toOne('MyApp.Foo'),
|
59
|
-
|
59
|
+
|
60
60
|
// test toOne relationship with computed type
|
61
61
|
relatedToComputed: SC.Record.toOne(function() {
|
62
|
-
// not using .get() to avoid another transform which will
|
62
|
+
// not using .get() to avoid another transform which will
|
63
63
|
// trigger an infinite loop
|
64
64
|
return (this.readAttribute('relatedToComputed').indexOf("foo")===0) ? MyApp.Foo : MyApp.Bar;
|
65
65
|
}),
|
66
|
-
|
66
|
+
|
67
67
|
// test readONly
|
68
68
|
readOnly: SC.Record.attr(String, { isEditable: NO })
|
69
|
-
|
69
|
+
|
70
70
|
});
|
71
|
-
|
71
|
+
|
72
72
|
MyApp.Bar = SC.Record.extend({
|
73
73
|
parent: SC.Record.toOne('MyApp.Foo', { aggregate: YES }),
|
74
74
|
relatedMany: SC.Record.toMany('MyApp.Foo', { aggregate: YES })
|
75
75
|
});
|
76
|
-
|
76
|
+
|
77
77
|
SC.RunLoop.begin();
|
78
78
|
storeKeys = MyApp.store.loadRecords(MyApp.Foo, [
|
79
|
-
{
|
80
|
-
guid: 'foo1',
|
81
|
-
firstName: "John",
|
82
|
-
lastName: "Doe",
|
79
|
+
{
|
80
|
+
guid: 'foo1',
|
81
|
+
firstName: "John",
|
82
|
+
lastName: "Doe",
|
83
83
|
date: "2009-03-01T20:30-08:00",
|
84
84
|
dateTime: new Date(1235939425000),
|
85
85
|
anArray: ['one', 'two', 'three'],
|
@@ -87,11 +87,11 @@ module("SC.RecordAttribute core methods", {
|
|
87
87
|
aNumber: '123',
|
88
88
|
readOnly: 'foo1'
|
89
89
|
},
|
90
|
-
|
91
|
-
{
|
92
|
-
guid: 'foo2',
|
93
|
-
firstName: "Jane",
|
94
|
-
lastName: "Doe",
|
90
|
+
|
91
|
+
{
|
92
|
+
guid: 'foo2',
|
93
|
+
firstName: "Jane",
|
94
|
+
lastName: "Doe",
|
95
95
|
relatedTo: 'foo1',
|
96
96
|
relatedToAggregate: 'bar1',
|
97
97
|
dateTime: "2009-03-01T20:30:25Z",
|
@@ -100,39 +100,39 @@ module("SC.RecordAttribute core methods", {
|
|
100
100
|
aNumber: '123',
|
101
101
|
nonIsoDate: "2009/06/10 8:55:50 +0000"
|
102
102
|
},
|
103
|
-
|
104
|
-
{
|
105
|
-
guid: 'foo3',
|
106
|
-
firstName: "Alex",
|
107
|
-
lastName: "Doe",
|
103
|
+
|
104
|
+
{
|
105
|
+
guid: 'foo3',
|
106
|
+
firstName: "Alex",
|
107
|
+
lastName: "Doe",
|
108
108
|
relatedToComputed: 'bar1',
|
109
109
|
dateTime: SC.DateTime.create(1235939425000),
|
110
110
|
anArray: ['one', 'two', 'three'],
|
111
111
|
anObject: { 'key1': 'value1', 'key2': 'value2' },
|
112
112
|
aNumber: '123'
|
113
113
|
}
|
114
|
-
|
114
|
+
|
115
115
|
]);
|
116
|
-
|
116
|
+
|
117
117
|
MyApp.store.loadRecords(MyApp.Bar, [
|
118
118
|
{ guid: 'bar1', city: "Chicago", parent: 'foo2', relatedMany: ['foo1', 'foo2'] }
|
119
119
|
]);
|
120
|
-
|
120
|
+
|
121
121
|
SC.RunLoop.end();
|
122
|
-
|
122
|
+
|
123
123
|
rec = MyApp.store.find(MyApp.Foo, 'foo1');
|
124
124
|
rec2 = MyApp.store.find(MyApp.Foo, 'foo2');
|
125
125
|
rec3 = MyApp.store.find(MyApp.Foo, 'foo3');
|
126
|
-
|
126
|
+
|
127
127
|
bar = MyApp.store.find(MyApp.Bar, 'bar1');
|
128
128
|
equals(rec.storeKey, storeKeys[0], 'should find record');
|
129
|
-
|
129
|
+
|
130
130
|
}
|
131
131
|
});
|
132
132
|
|
133
133
|
// ..........................................................
|
134
134
|
// READING
|
135
|
-
//
|
135
|
+
//
|
136
136
|
|
137
137
|
test("pass-through should return builtin value" ,function() {
|
138
138
|
equals(rec.get('firstName'), 'John', 'reading prop should get attr value');
|
@@ -190,7 +190,7 @@ test("reading computed default value", function() {
|
|
190
190
|
|
191
191
|
// ..........................................................
|
192
192
|
// WRITING
|
193
|
-
//
|
193
|
+
//
|
194
194
|
|
195
195
|
test("writing pass-through should simply set value", function() {
|
196
196
|
rec.set("firstName", "Foo");
|
@@ -201,7 +201,7 @@ test("writing pass-through should simply set value", function() {
|
|
201
201
|
|
202
202
|
rec.set("firstName", YES);
|
203
203
|
equals(rec.readAttribute("firstName"), YES, "should write bool");
|
204
|
-
|
204
|
+
|
205
205
|
});
|
206
206
|
|
207
207
|
test("writing when isEditable is NO should ignore", function() {
|
@@ -217,7 +217,7 @@ test("writing a value should override default value", function() {
|
|
217
217
|
});
|
218
218
|
|
219
219
|
test("writing a string to a number attribute should store a number" ,function() {
|
220
|
-
equals(rec.set('aNumber', "456"), rec, 'returns
|
220
|
+
equals(rec.set('aNumber', "456"), rec, 'returns receiver');
|
221
221
|
equals(rec.get('aNumber'), 456, 'should have new value');
|
222
222
|
equals(typeof rec.get('aNumber'), 'number', 'new value should be a number');
|
223
223
|
});
|
@@ -229,27 +229,27 @@ test("writing a date should generate an ISO date" ,function() {
|
|
229
229
|
var utcDate = new Date(Number(date) + (date.getTimezoneOffset() * 60000)); // Adjust for timezone offset
|
230
230
|
utcDate.getTimezoneOffset = function(){ return 0; }; // Hack the offset to respond 0
|
231
231
|
|
232
|
-
equals(rec.set('date', utcDate), rec, 'returns
|
232
|
+
equals(rec.set('date', utcDate), rec, 'returns receiver');
|
233
233
|
equals(rec.readAttribute('date'), '2009-04-02T05:28:03Z', 'should have time in ISO format');
|
234
234
|
});
|
235
235
|
|
236
236
|
test("writing an attribute should make relationship aggregate dirty" ,function() {
|
237
237
|
equals(bar.get('status'), SC.Record.READY_CLEAN, "precond - bar should be READY_CLEAN");
|
238
238
|
equals(rec2.get('status'), SC.Record.READY_CLEAN, "precond - rec2 should be READY_CLEAN");
|
239
|
-
|
239
|
+
|
240
240
|
bar.set('city', 'Oslo');
|
241
241
|
bar.get('store').flush();
|
242
|
-
|
242
|
+
|
243
243
|
equals(rec2.get('status'), SC.Record.READY_DIRTY, "foo2 should be READY_DIRTY");
|
244
244
|
});
|
245
245
|
|
246
246
|
test("writing an attribute should make many relationship aggregate dirty" ,function() {
|
247
247
|
equals(bar.get('status'), SC.Record.READY_CLEAN, "precond - bar should be READY_CLEAN");
|
248
248
|
equals(rec2.get('status'), SC.Record.READY_CLEAN, "precond - rec2 should be READY_CLEAN");
|
249
|
-
|
249
|
+
|
250
250
|
bar.set('city', 'Oslo');
|
251
251
|
bar.get('store').flush();
|
252
|
-
|
252
|
+
|
253
253
|
equals(rec.get('status'), SC.Record.READY_DIRTY, "foo1 should be READY_DIRTY");
|
254
254
|
equals(rec2.get('status'), SC.Record.READY_DIRTY, "foo2 should be READY_DIRTY");
|
255
255
|
});
|
@@ -257,10 +257,25 @@ test("writing an attribute should make many relationship aggregate dirty" ,funct
|
|
257
257
|
test("writing an attribute should make many relationship aggregate dirty and add the aggregate to the store" ,function() {
|
258
258
|
equals(bar.get('status'), SC.Record.READY_CLEAN, "precond - bar should be READY_CLEAN");
|
259
259
|
equals(rec2.get('status'), SC.Record.READY_CLEAN, "precond - rec2 should be READY_CLEAN");
|
260
|
-
|
260
|
+
|
261
261
|
bar.set('city', 'Oslo');
|
262
262
|
|
263
263
|
var store = bar.get('store');
|
264
264
|
ok(store.changelog.contains(rec.get('storeKey')), "foo1 should be in the store's changelog");
|
265
265
|
ok(store.changelog.contains(rec2.get('storeKey')), "foo2 should be in the store's changelog");
|
266
266
|
});
|
267
|
+
|
268
|
+
test("adding attribute with non existing class should throw error", function() {
|
269
|
+
MyApp.InvalidModel = SC.Record.extend({
|
270
|
+
foo: SC.Record.attr("SomethingSomethingSomething")
|
271
|
+
});
|
272
|
+
|
273
|
+
var message;
|
274
|
+
try {
|
275
|
+
MyApp.InvalidModel.prototype.foo.typeClass();
|
276
|
+
} catch (x) {
|
277
|
+
message = x;
|
278
|
+
}
|
279
|
+
|
280
|
+
same(message, 'SomethingSomethingSomething could not be found');
|
281
|
+
});
|
@@ -11,13 +11,13 @@ module("SC.NestedStore#commitChangesFromNestedStore", {
|
|
11
11
|
SC.RunLoop.begin();
|
12
12
|
|
13
13
|
parent = SC.Store.create();
|
14
|
-
|
14
|
+
|
15
15
|
json = {
|
16
16
|
string: "string",
|
17
17
|
number: 23,
|
18
18
|
bool: YES
|
19
19
|
};
|
20
|
-
|
20
|
+
|
21
21
|
storeKey = SC.Store.generateStoreKey();
|
22
22
|
|
23
23
|
store = parent.chain();
|
@@ -34,22 +34,22 @@ module("SC.NestedStore#commitChangesFromNestedStore", {
|
|
34
34
|
});
|
35
35
|
|
36
36
|
test("copies changed data hashes, statuses, and revisions", function() {
|
37
|
-
|
37
|
+
|
38
38
|
SC.RunLoop.begin();
|
39
|
-
|
39
|
+
|
40
40
|
// verify preconditions
|
41
41
|
equals(store.readDataHash(storeKey), null, 'precond - should not have data yet');
|
42
42
|
ok(child.chainedChanges.contains(storeKey), 'precond - child changes should include storeKey');
|
43
|
-
|
43
|
+
|
44
44
|
// perform action
|
45
45
|
equals(store.commitChangesFromNestedStore(child, child.chainedChanges, NO), store, 'should return receiver');
|
46
46
|
SC.RunLoop.end();
|
47
|
-
|
47
|
+
|
48
48
|
// verify new status
|
49
49
|
equals(store.readDataHash(storeKey), json, 'now should have json');
|
50
50
|
equals(store.readStatus(storeKey), SC.Record.READY_DIRTY, 'now should have status');
|
51
|
-
equals(store.revisions[storeKey], child.revisions[storeKey], 'now shoulave have revision from child');
|
52
|
-
|
51
|
+
equals(store.revisions[storeKey], child.revisions[storeKey], 'now shoulave have revision from child');
|
52
|
+
|
53
53
|
});
|
54
54
|
|
55
55
|
test("adds lock on any items not already locked", function() {
|
@@ -58,40 +58,40 @@ test("adds lock on any items not already locked", function() {
|
|
58
58
|
|
59
59
|
var storeKey2 = SC.Store.generateStoreKey();
|
60
60
|
var json2 = { kind: "json2" };
|
61
|
-
|
61
|
+
|
62
62
|
// verify preconditions
|
63
63
|
store.readDataHash(storeKey);
|
64
64
|
ok(store.locks[storeKey], 'precond - storeKey should have lock');
|
65
65
|
ok(!store.locks[storeKey2], 'precond - storeKey2 should not have lock');
|
66
|
-
|
66
|
+
|
67
67
|
// write another record into child store to commit changes.
|
68
68
|
child.writeDataHash(storeKey2, json2, SC.Record.READY_DIRTY);
|
69
69
|
child.dataHashDidChange(storeKey2);
|
70
|
-
|
70
|
+
|
71
71
|
var changes = child.chainedChanges ;
|
72
72
|
ok(changes.contains(storeKey), 'precond - child.chainedChanges should contain storeKey');
|
73
73
|
ok(changes.contains(storeKey2), 'precond - child.chainedChanges should contain storeKey2');
|
74
|
-
|
74
|
+
|
75
75
|
// now commit back to parent
|
76
|
-
equals(store.commitChangesFromNestedStore(child, changes, NO), store, 'should return
|
76
|
+
equals(store.commitChangesFromNestedStore(child, changes, NO), store, 'should return receiver');
|
77
77
|
SC.RunLoop.end();
|
78
|
-
|
78
|
+
|
79
79
|
// and verify that both have locks
|
80
80
|
ok(store.locks[storeKey], 'storeKey should have lock after commit (actual: %@)'.fmt(store.locks[storeKey]));
|
81
81
|
ok(store.locks[storeKey2], 'storeKey2 should have lock after commit (actual: %@)'.fmt(store.locks[storeKey2]));
|
82
|
-
|
82
|
+
|
83
83
|
});
|
84
84
|
|
85
|
-
test("adds items in chainedChanges to
|
85
|
+
test("adds items in chainedChanges to receiver chainedChanges", function() {
|
86
86
|
|
87
87
|
SC.RunLoop.begin();
|
88
88
|
|
89
89
|
var key1 = SC.Store.generateStoreKey();
|
90
90
|
|
91
91
|
store.dataHashDidChange(key1);
|
92
|
-
|
92
|
+
|
93
93
|
ok(child.chainedChanges.contains(storeKey), 'precond - child.chainedChanges should contain store key');
|
94
|
-
|
94
|
+
|
95
95
|
equals(store.commitChangesFromNestedStore(child, child.chainedChanges, NO), store, 'should return receiver');
|
96
96
|
SC.RunLoop.end();
|
97
97
|
|
@@ -101,36 +101,36 @@ test("adds items in chainedChanges to reciever chainedChanges", function() {
|
|
101
101
|
});
|
102
102
|
|
103
103
|
test("should set hasChanges to YES if has changes", function() {
|
104
|
-
|
104
|
+
|
105
105
|
SC.RunLoop.begin();
|
106
|
-
|
106
|
+
|
107
107
|
var changes = child.chainedChanges;
|
108
108
|
ok(changes.length>0, 'precond - should have some changes in child');
|
109
109
|
equals(store.get('hasChanges'), NO, 'precond - store should not have changes');
|
110
|
-
|
110
|
+
|
111
111
|
store.commitChangesFromNestedStore(child, changes, NO);
|
112
112
|
equals(store.get('hasChanges'), YES, 'store should now have changes');
|
113
113
|
});
|
114
114
|
|
115
115
|
test("should set hasChanges to NO if no changes", function() {
|
116
|
-
|
116
|
+
|
117
117
|
SC.RunLoop.begin();
|
118
|
-
|
118
|
+
|
119
119
|
child = store.chain() ; // get a new child store
|
120
|
-
|
120
|
+
|
121
121
|
var changes = child.chainedChanges || SC.Set.create();
|
122
122
|
ok(!changes || !changes.length, 'precond - should have not have changes in child');
|
123
123
|
equals(store.get('hasChanges'), NO, 'precond - store should not have changes');
|
124
|
-
|
124
|
+
|
125
125
|
store.commitChangesFromNestedStore(child, changes, NO);
|
126
126
|
SC.RunLoop.end();
|
127
|
-
|
127
|
+
|
128
128
|
equals(store.get('hasChanges'), NO, 'store should NOT now have changes');
|
129
129
|
});
|
130
130
|
|
131
131
|
// ..........................................................
|
132
132
|
// SPECIAL CASES
|
133
|
-
//
|
133
|
+
//
|
134
134
|
|
135
135
|
test("committing changes should chain back each step", function() {
|
136
136
|
|
@@ -140,18 +140,18 @@ test("committing changes should chain back each step", function() {
|
|
140
140
|
equals(child.readDataHash(storeKey), json, 'precond - child should have data');
|
141
141
|
equals(store.readDataHash(storeKey), null, 'precond - store should not have data');
|
142
142
|
equals(parent.readDataHash(storeKey), null, 'precond - parent should not have data');
|
143
|
-
|
143
|
+
|
144
144
|
// do commits
|
145
145
|
child.commitChanges();
|
146
146
|
|
147
147
|
equals(store.get('hasChanges'), YES, 'store should now have changes');
|
148
148
|
equals(store.readDataHash(storeKey), json, 'store should now have json');
|
149
|
-
|
149
|
+
|
150
150
|
store.commitChanges();
|
151
151
|
equals(store.get('hasChanges'), NO, 'store should no longer have changes');
|
152
152
|
equals(parent.readDataHash(storeKey), json, 'parent should now have json');
|
153
153
|
SC.RunLoop.end();
|
154
|
-
|
154
|
+
|
155
155
|
});
|
156
156
|
|
157
157
|
|