extjs-mvc 0.4.0.f → 0.4.0.g
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/extjs-mvc +0 -3
- data/lib/extjs-mvc.rb +10 -6
- data/lib/extjs-mvc/api.rb +0 -1
- metadata +8 -84
- data/lib/src/App.js +0 -219
- data/lib/src/MVC.js +0 -260
- data/lib/src/Presenter.js +0 -52
- data/lib/src/README.rdoc +0 -69
- data/lib/src/controller/Controller.js +0 -278
- data/lib/src/controller/CrudController.js +0 -460
- data/lib/src/lib/Array.js +0 -26
- data/lib/src/lib/Booter.js +0 -416
- data/lib/src/lib/ClassManager.js +0 -191
- data/lib/src/lib/ControllerClassManager.js +0 -95
- data/lib/src/lib/Dependencies.js +0 -44
- data/lib/src/lib/DispatchMatcher.js +0 -98
- data/lib/src/lib/Dispatcher.js +0 -129
- data/lib/src/lib/Environment.js +0 -43
- data/lib/src/lib/Inflector.js +0 -155
- data/lib/src/lib/ModelClassManager.js +0 -19
- data/lib/src/lib/Route.js +0 -139
- data/lib/src/lib/Router.js +0 -282
- data/lib/src/lib/String.js +0 -94
- data/lib/src/lib/ViewClassManager.js +0 -229
- data/lib/src/lib/notes.txt +0 -32
- data/lib/src/model/AdapterManager.js +0 -30
- data/lib/src/model/Association.js +0 -26
- data/lib/src/model/Base.js +0 -63
- data/lib/src/model/BelongsToAssociation.js +0 -116
- data/lib/src/model/Cache.js +0 -131
- data/lib/src/model/HasManyAssociation.js +0 -160
- data/lib/src/model/Model.js +0 -331
- data/lib/src/model/UrlBuilder.js +0 -106
- data/lib/src/model/adapters/AbstractAdapter.js +0 -296
- data/lib/src/model/adapters/MemoryAdapter.js +0 -103
- data/lib/src/model/adapters/RESTAdapter.js +0 -345
- data/lib/src/model/adapters/RESTJSONAdapter.js +0 -68
- data/lib/src/model/adapters/notes.txt +0 -42
- data/lib/src/model/associations/Association.js +0 -192
- data/lib/src/model/associations/notes.txt +0 -87
- data/lib/src/model/validations/Errors.js +0 -136
- data/lib/src/model/validations/Plugin.js +0 -139
- data/lib/src/model/validations/Validations.js +0 -276
- data/lib/src/notes/Charts.graffle +0 -0
- data/lib/src/overrides/Ext.Component.js +0 -21
- data/lib/src/overrides/Ext.extend.js +0 -142
- data/lib/src/spec/Array.spec.js +0 -15
- data/lib/src/spec/ExtMVC.spec.js +0 -65
- data/lib/src/spec/Model.spec.js +0 -370
- data/lib/src/spec/OS.spec.js +0 -83
- data/lib/src/spec/Router.spec.js +0 -99
- data/lib/src/spec/SpecHelper.js +0 -106
- data/lib/src/spec/String.spec.js +0 -83
- data/lib/src/spec/model/AbstractAdapter.spec.js +0 -49
- data/lib/src/spec/model/Associations.spec.js +0 -99
- data/lib/src/spec/model/Cache.spec.js +0 -5
- data/lib/src/spec/model/RESTAdapter.spec.js +0 -19
- data/lib/src/spec/model/ValidationErrors.spec.js +0 -64
- data/lib/src/spec/model/Validations.spec.js +0 -166
- data/lib/src/spec/model/ValidationsPlugin.spec.js +0 -108
- data/lib/src/spec/suite.html +0 -60
- data/lib/src/specs-old/JSSpec.css +0 -216
- data/lib/src/specs-old/JSSpec.js +0 -1512
- data/lib/src/specs-old/all.html +0 -66
- data/lib/src/specs-old/base.js +0 -14
- data/lib/src/specs-old/controller.js +0 -17
- data/lib/src/specs-old/diff_match_patch.js +0 -1
- data/lib/src/specs-old/model.js +0 -70
- data/lib/src/specs-old/route.js +0 -38
- data/lib/src/specs-old/router.js +0 -59
- data/lib/src/specs-old/string.js +0 -22
- data/lib/src/testrunner/JSpecFormatter.js +0 -111
- data/lib/src/testrunner/TestClient.js +0 -181
- data/lib/src/testrunner/TestGrid.js +0 -351
- data/lib/src/testrunner/TestRunner.js +0 -110
- data/lib/src/testrunner/TestViewport.js +0 -94
- data/lib/src/vendor.yml +0 -29
- data/lib/src/vendor/ext-3.1.1/vendor.yml +0 -16
- data/lib/src/view/FormWindow.js +0 -184
- data/lib/src/view/HasManyEditorGridPanel.js +0 -211
- data/lib/src/view/scaffold/Edit.js +0 -46
- data/lib/src/view/scaffold/Index.js +0 -561
- data/lib/src/view/scaffold/New.js +0 -20
- data/lib/src/view/scaffold/ScaffoldFormPanel.js +0 -255
data/lib/src/spec/ExtMVC.spec.js
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
Screw.Unit(function() {
|
2
|
-
describe("ExtMVC", function() {
|
3
|
-
describe("environments", function() {
|
4
|
-
it("should default to the production environment", function() {
|
5
|
-
expect(ExtMVC.getCurrentEnvironment()).to(equal, 'production');
|
6
|
-
});
|
7
|
-
|
8
|
-
it("should return current environment settings", function() {
|
9
|
-
expect(ExtMVC.getCurrentEnvironmentSettings()).to(equal, {});
|
10
|
-
});
|
11
|
-
|
12
|
-
it("should allow retrieval of existing environment settings", function() {
|
13
|
-
var prod = ExtMVC.getEnvironmentSettings('production');
|
14
|
-
expect(prod).to(equal, {});
|
15
|
-
});
|
16
|
-
|
17
|
-
it("should allow specification of environment settings to an existing environment", function() {
|
18
|
-
expect(ExtMVC.getEnvironmentSettings('production')).to(equal, {});
|
19
|
-
|
20
|
-
ExtMVC.addEnvironmentSettings('production', {myKey: 'myValue'});
|
21
|
-
expect(ExtMVC.getEnvironmentSettings('production').myKey).to(equal, 'myValue');
|
22
|
-
});
|
23
|
-
|
24
|
-
it("should allow specification of environment settings to a new environment", function() {
|
25
|
-
var mySettings = {key: 'value'};
|
26
|
-
expect(ExtMVC.getEnvironmentSettings('newEnv')).to(equal, null);
|
27
|
-
|
28
|
-
ExtMVC.addEnvironmentSettings('newEnv', mySettings);
|
29
|
-
expect(ExtMVC.getEnvironmentSettings('newEnv')).to(equal, mySettings);
|
30
|
-
});
|
31
|
-
|
32
|
-
describe("when changing environment", function() {
|
33
|
-
it("should allow the current environment to be changed if the new environment is valid", function() {
|
34
|
-
expect(ExtMVC.getCurrentEnvironment()).to(equal, 'production');
|
35
|
-
|
36
|
-
//we need to add this environment first to make it valid
|
37
|
-
ExtMVC.addEnvironmentSettings('development', {key: 'value'});
|
38
|
-
|
39
|
-
ExtMVC.setCurrentEnvironment('development');
|
40
|
-
expect(ExtMVC.getCurrentEnvironment()).to(equal, 'development');
|
41
|
-
});
|
42
|
-
|
43
|
-
it("should not allow the current environment to be changed if the new environment does not exist", function() {
|
44
|
-
ExtMVC.setCurrentEnvironment('notReal');
|
45
|
-
expect(ExtMVC.getCurrentEnvironment()).to_not(equal, 'notReal');
|
46
|
-
});
|
47
|
-
|
48
|
-
it("should fire an environment-changed event", function() {
|
49
|
-
var newEnv = '', newConfig = {};
|
50
|
-
var devSettings = {key: 'value'};
|
51
|
-
|
52
|
-
//add another environment to be able to change to
|
53
|
-
ExtMVC.addEnvironmentSettings('development', devSettings);
|
54
|
-
|
55
|
-
ExtMVC.on('environment-changed', function(n, c) {newEnv = n; newConfig = c;}, this);
|
56
|
-
|
57
|
-
ExtMVC.setCurrentEnvironment('development');
|
58
|
-
|
59
|
-
expect(newEnv).to(equal, 'development');
|
60
|
-
expect(newConfig).to(equal, devSettings);
|
61
|
-
});
|
62
|
-
});
|
63
|
-
});
|
64
|
-
});
|
65
|
-
});
|
data/lib/src/spec/Model.spec.js
DELETED
@@ -1,370 +0,0 @@
|
|
1
|
-
Screw.Unit(function() {
|
2
|
-
//keep track of the object to which models are currently assigned
|
3
|
-
var ns = ExtMVC.model.modelNamespace;
|
4
|
-
|
5
|
-
//Uses some test models set up in SpecHelper.js
|
6
|
-
user = new ns.User({
|
7
|
-
id: 100,
|
8
|
-
first_name: 'William',
|
9
|
-
last_name: 'Adama',
|
10
|
-
email: 'adama@bsg.net'
|
11
|
-
});
|
12
|
-
|
13
|
-
blogPost = new ns.BlogPost({
|
14
|
-
id: 1,
|
15
|
-
user_id: 100,
|
16
|
-
title: 'Test Post',
|
17
|
-
content: "Frak the odds, we're going to find her"
|
18
|
-
});
|
19
|
-
|
20
|
-
describe("Models", function() {
|
21
|
-
describe("when defining models", function() {
|
22
|
-
before(function() {
|
23
|
-
//we redefine these several times in these blocks so delete between each test
|
24
|
-
delete ns.AnotherModel;
|
25
|
-
delete ns.SpecialModel;
|
26
|
-
});
|
27
|
-
|
28
|
-
it("should create the model immediately if it does not extend any other models", function() {
|
29
|
-
expect(typeof ns.AnotherModel).to(equal, "undefined");
|
30
|
-
|
31
|
-
ExtMVC.model.define('AnotherModel', {fields: [{name: 'title', type: 'string'}]});
|
32
|
-
expect(typeof ns.AnotherModel).to(equal, "function");
|
33
|
-
});
|
34
|
-
|
35
|
-
describe("when checking to see if the model has already been defined", function() {
|
36
|
-
it("should return false when trying to define a new model", function() {
|
37
|
-
expect(ExtMVC.model.isAlreadyDefined('MySuperModel')).to(equal, false);
|
38
|
-
});
|
39
|
-
|
40
|
-
it("should return true when trying to define a model that already exists", function() {
|
41
|
-
expect(ExtMVC.model.isAlreadyDefined('User')).to(equal, true);
|
42
|
-
});
|
43
|
-
|
44
|
-
it("should return true when trying to define a model that is already in the pending creation queue", function() {
|
45
|
-
//Add a fake model that depends on another model which hasn't yet been created
|
46
|
-
ExtMVC.model.define("AnotherNewModel", {extend: "NonExistantModel"});
|
47
|
-
|
48
|
-
//AnotherNewModel hasn't actually been created at this point
|
49
|
-
expect(typeof ns.AnotherNewModel).to(equal, "undefined");
|
50
|
-
expect(ExtMVC.model.isAlreadyDefined('AnotherNewModel')).to(equal, true);
|
51
|
-
});
|
52
|
-
});
|
53
|
-
|
54
|
-
describe("which extend other models", function() {
|
55
|
-
after(function() {
|
56
|
-
delete ns.RichUser; delete ns.AnotherModel;
|
57
|
-
});
|
58
|
-
|
59
|
-
it("should create the model immediately if it extends a model that has already been defined", function() {
|
60
|
-
//make sure our superclass has been defined already
|
61
|
-
expect(typeof ns.User).to(equal, "function");
|
62
|
-
|
63
|
-
ExtMVC.model.define('RichUser', {extend: 'User', monies: 'many'});
|
64
|
-
expect(typeof ns.RichUser).to(equal, "function");
|
65
|
-
});
|
66
|
-
|
67
|
-
it("should not create the model immediately if the model it extends has not yet been defined", function() {
|
68
|
-
//make sure our superclass model hasn't been defined yet
|
69
|
-
expect(typeof ns.SpecialModel).to(equal, "undefined");
|
70
|
-
|
71
|
-
ExtMVC.model.define('AnotherModel', {fields: [{name: 'title', type: 'string'}], extend: 'SpecialModel'});
|
72
|
-
|
73
|
-
expect(typeof ns.AnotherModel).to(equal, "undefined");
|
74
|
-
});
|
75
|
-
|
76
|
-
it("should add the create config to an internal object if the model it extends has not yet been defined", function() {
|
77
|
-
var previousLength = ExtMVC.model.getModelsPendingDefinitionOf('SpecialModel').length;
|
78
|
-
|
79
|
-
ExtMVC.model.define('AnotherModel', {fields: [{name: 'title', type: 'string'}], extend: 'SpecialModel'});
|
80
|
-
|
81
|
-
var p = ExtMVC.model.getModelsPendingDefinitionOf('SpecialModel');
|
82
|
-
expect(p.length).to(equal, previousLength + 1);
|
83
|
-
expect(p[0].name).to(equal, 'AnotherModel');
|
84
|
-
});
|
85
|
-
});
|
86
|
-
});
|
87
|
-
|
88
|
-
describe("the pendingCreation queue", function() {
|
89
|
-
//add a couple of fake configs to the queue...
|
90
|
-
var peonUserConfig = {displayName: function() {return 'Peon';}};
|
91
|
-
var noobUserConfig = {displayName: function() {return 'Noob';}};
|
92
|
-
|
93
|
-
var m = ExtMVC.model;
|
94
|
-
m.pendingCreation = {'User': [
|
95
|
-
{name: 'PeonUser', config: peonUserConfig},
|
96
|
-
{name: 'NoobUser', config: noobUserConfig}
|
97
|
-
]};
|
98
|
-
|
99
|
-
it("should return an array of all model definitions waiting for the creation of a given model", function() {
|
100
|
-
var p = ExtMVC.model.getModelsPendingDefinitionOf('User');
|
101
|
-
|
102
|
-
expect(p.length).to(equal, 2);
|
103
|
-
expect(p[0].name).to(equal, 'PeonUser');
|
104
|
-
expect(p[1].name).to(equal, 'NoobUser');
|
105
|
-
});
|
106
|
-
|
107
|
-
it("should add model definition objects to the queue", function() {
|
108
|
-
ExtMVC.model.setModelPendingDefinitionOf('User', 'NormalUser', {displayName: function() {return 'Normal';}});
|
109
|
-
|
110
|
-
var p = ExtMVC.model.getModelsPendingDefinitionOf('User');
|
111
|
-
expect(p.length).to(equal, 3);
|
112
|
-
expect(p[2].name).to(equal, 'NormalUser');
|
113
|
-
});
|
114
|
-
});
|
115
|
-
|
116
|
-
describe("when creating a model", function() {
|
117
|
-
before(function() {
|
118
|
-
ExtMVC.model.define('NewModel', {fields: [{name: 'name', type: 'string'}]});
|
119
|
-
});
|
120
|
-
|
121
|
-
after(function() {
|
122
|
-
delete ns.NewModel; delete ns.MyNewModel;
|
123
|
-
});
|
124
|
-
|
125
|
-
it("should create the model within ExtMVC.model.modelNamespace", function() {
|
126
|
-
expect(typeof ns.MyNewModel).to(equal, 'undefined');
|
127
|
-
ExtMVC.model.create('MyNewModel', {fields: [{name: 'title', type: 'string'}]});
|
128
|
-
|
129
|
-
expect(typeof ns.MyNewModel).to(equal, 'function');
|
130
|
-
});
|
131
|
-
|
132
|
-
it("make all defined methods available on that model", function() {
|
133
|
-
expect(typeof(user.displayName)).to(equal, "function");
|
134
|
-
});
|
135
|
-
|
136
|
-
it("should not make the special classMethods property available", function() {
|
137
|
-
expect(typeof(user.classMethods)).to(equal, "undefined");
|
138
|
-
});
|
139
|
-
|
140
|
-
it("should add all classMethods to the model class instead of each instance", function() {
|
141
|
-
expect(typeof(ns.User.testClassMethod)).to(equal, "function");
|
142
|
-
});
|
143
|
-
|
144
|
-
it("should default the primary key to 'id'", function() {
|
145
|
-
expect(user.primaryKey).to(equal, 'id');
|
146
|
-
});
|
147
|
-
|
148
|
-
it("should allow specification of a different primary key to 'id'", function() {
|
149
|
-
ExtMVC.model.create("SpecialModel", {
|
150
|
-
fields: [{name: 'someField', type: 'string'}],
|
151
|
-
primaryKey: 'someField'
|
152
|
-
});
|
153
|
-
|
154
|
-
var special = new ns.SpecialModel({someField: 'someValue'});
|
155
|
-
|
156
|
-
expect(special.primaryKey).to(equal, 'someField');
|
157
|
-
});
|
158
|
-
|
159
|
-
// it("should set its modelClass property as a reference to the class definition", function() {
|
160
|
-
// expect(user.modelClass).to(equal, ns.User);
|
161
|
-
// });
|
162
|
-
|
163
|
-
it("should inherit all functions from Ext.data.Record", function() {
|
164
|
-
var funcs = ['beginEdit', 'cancelEdit', 'clearError', 'commit', 'copy', 'endEdit', 'get',
|
165
|
-
'getChanges', 'hasError', 'isModified', 'join', 'override', 'reject', 'set'];
|
166
|
-
|
167
|
-
var myInstance = new ns.NewModel({name: 'Ed'});
|
168
|
-
|
169
|
-
Ext.each(funcs, function(functionName) {
|
170
|
-
expect(typeof myInstance[functionName]).to(equal, "function");
|
171
|
-
}, this);
|
172
|
-
});
|
173
|
-
|
174
|
-
it("should inherit all properties from Ext.data.Record", function() {
|
175
|
-
var props = ['dirty', 'editing', 'error', 'id', 'modified'];
|
176
|
-
|
177
|
-
var myInstance = new ns.NewModel({name: 'Ed'});
|
178
|
-
|
179
|
-
Ext.each(props, function(propertyName) {
|
180
|
-
expect(typeof myInstance[propertyName]).to_not(equal, "undefined");
|
181
|
-
}, this);
|
182
|
-
});
|
183
|
-
});
|
184
|
-
|
185
|
-
describe("after creation", function() {
|
186
|
-
it("should check the pending creation array and create any models that depended on this model's existence", function() {
|
187
|
-
//TODO: Work out how to test that getModelsPendingDefinitionOf has definitely been called here
|
188
|
-
|
189
|
-
});
|
190
|
-
});
|
191
|
-
|
192
|
-
describe("A Model instance", function() {
|
193
|
-
var newUser = new ns.User({
|
194
|
-
first_name: 'Saul',
|
195
|
-
last_name: 'Tigh',
|
196
|
-
email: 'saul@tigh.net'
|
197
|
-
});
|
198
|
-
|
199
|
-
describe("which has not yet been saved for the first time (has no primary key set yet)", function() {
|
200
|
-
it("should should return true to newRecord()", function() {
|
201
|
-
expect(newUser.newRecord()).to(equal, true);
|
202
|
-
});
|
203
|
-
|
204
|
-
it("should assign constructor parameters to the data object like a normal Ext.data.Record", function() {
|
205
|
-
expect(newUser.data.first_name).to(equal, 'Saul');
|
206
|
-
expect(newUser.data.last_name).to(equal, 'Tigh');
|
207
|
-
expect(newUser.data.email).to(equal, 'saul@tigh.net');
|
208
|
-
});
|
209
|
-
});
|
210
|
-
|
211
|
-
describe("name functions", function() {
|
212
|
-
var lmn;
|
213
|
-
|
214
|
-
before(function() {
|
215
|
-
ExtMVC.model.define("LongModelName", {fields: [{}]});
|
216
|
-
lmn = new ns.LongModelName({});
|
217
|
-
});
|
218
|
-
|
219
|
-
after(function() {
|
220
|
-
delete ns.LongModelName;
|
221
|
-
});
|
222
|
-
|
223
|
-
it("should keep the modelName as defined", function() {
|
224
|
-
expect(newUser.modelName).to(equal, 'User');
|
225
|
-
expect((new ns.BlogPost()).modelName).to(equal, 'BlogPost');
|
226
|
-
});
|
227
|
-
|
228
|
-
it("should return a tablename based on the model name", function() {
|
229
|
-
expect(newUser.tableName).to(equal, 'users');
|
230
|
-
expect(lmn.tableName).to(equal, 'long_model_names');
|
231
|
-
});
|
232
|
-
|
233
|
-
it("should return a foreignKeyName based on the model name", function() {
|
234
|
-
expect(newUser.foreignKeyName).to(equal, "user_id");
|
235
|
-
expect(lmn.foreignKeyName).to(equal, 'long_model_name_id');
|
236
|
-
});
|
237
|
-
});
|
238
|
-
|
239
|
-
describe("which has already been saved (has a primary key set)", function() {
|
240
|
-
var existingUser = new ns.User({
|
241
|
-
first_name: 'Kara',
|
242
|
-
last_name: 'Thrace',
|
243
|
-
email: 'starbuck@bsg.net',
|
244
|
-
id: 1
|
245
|
-
});
|
246
|
-
|
247
|
-
it("should return false to newRecord()", function() {
|
248
|
-
expect(existingUser.newRecord()).to(equal, false);
|
249
|
-
});
|
250
|
-
});
|
251
|
-
});
|
252
|
-
|
253
|
-
describe("Extending another Model", function() {
|
254
|
-
ExtMVC.model.define("SuperUser", {
|
255
|
-
extend: 'User',
|
256
|
-
fields: [
|
257
|
-
{name: 'is_admin', type: 'boolean'},
|
258
|
-
{name: 'password', type: 'string'},
|
259
|
-
|
260
|
-
//here we are _re_defining User's email property to be a number
|
261
|
-
{name: 'email', type: 'number'}
|
262
|
-
],
|
263
|
-
|
264
|
-
//overwrite superclass's version of this instance method
|
265
|
-
earlyJoiner: function() {
|
266
|
-
return true;
|
267
|
-
},
|
268
|
-
|
269
|
-
classMethods: {
|
270
|
-
//overwrite superclass's version of this class method
|
271
|
-
methodToOverwrite: function() {
|
272
|
-
return false;
|
273
|
-
}
|
274
|
-
}
|
275
|
-
});
|
276
|
-
|
277
|
-
var su = ns.SuperUser;
|
278
|
-
var newSu = new ns.SuperUser({first_name : 'Ed', last_name: 'Spencer'});
|
279
|
-
|
280
|
-
it("should inherit fields from the superclass", function() {
|
281
|
-
var superFieldCount = ns.User.prototype.fields.getCount();
|
282
|
-
var f = ns.SuperUser.prototype.fields;
|
283
|
-
|
284
|
-
//we added two additional fields in SuperUser definition (email is a _re_definition)
|
285
|
-
expect(f.getCount()).to(equal, superFieldCount + 2);
|
286
|
-
});
|
287
|
-
|
288
|
-
it("should overwrite any conflicting fields", function() {
|
289
|
-
var email = ns.SuperUser.prototype.fields.get('email');
|
290
|
-
|
291
|
-
expect(email.type).to(equal, "number");
|
292
|
-
});
|
293
|
-
|
294
|
-
it("should not overwrite the superclass's fields", function() {
|
295
|
-
var email = ns.User.prototype.fields.get('email');
|
296
|
-
|
297
|
-
expect(email.type).to(equal, "string");
|
298
|
-
});
|
299
|
-
|
300
|
-
it("should inherit instance methods from the superclass", function() {
|
301
|
-
expect(newSu.displayName()).to(equal, "Ed Spencer");
|
302
|
-
});
|
303
|
-
|
304
|
-
it("should overwrite conflicting instance methods", function() {
|
305
|
-
//the superclass' earlyJoiner method return false, test that this is overriden by subclass
|
306
|
-
expect(newSu.earlyJoiner()).to(equal, true);
|
307
|
-
});
|
308
|
-
|
309
|
-
it("should not overwrite the superclass's conflicting instance methods", function() {
|
310
|
-
newUser = new ns.User({id: 200});
|
311
|
-
expect(newUser.earlyJoiner()).to(equal, false);
|
312
|
-
});
|
313
|
-
|
314
|
-
it("should inherit class methods from the superclass", function() {
|
315
|
-
expect(typeof ns.SuperUser.testClassMethod).to(equal, "function");
|
316
|
-
});
|
317
|
-
|
318
|
-
it("should overwrite conflicting class methods", function() {
|
319
|
-
expect(ns.SuperUser.methodToOverwrite()).to(equal, false);
|
320
|
-
});
|
321
|
-
|
322
|
-
it("should not overwrite the superclass's conflicting class methods", function() {
|
323
|
-
expect(ns.User.methodToOverwrite()).to(equal, true);
|
324
|
-
});
|
325
|
-
});
|
326
|
-
|
327
|
-
describe("Plugins", function() {
|
328
|
-
var initializeCalled,
|
329
|
-
myPlugin = { initialize: Ext.emptyFn };
|
330
|
-
|
331
|
-
var normalPlugins = ExtMVC.model.plugins;
|
332
|
-
|
333
|
-
before(function() {
|
334
|
-
//clear out all plugins between tests
|
335
|
-
ExtMVC.model.plugins = [];
|
336
|
-
});
|
337
|
-
|
338
|
-
after(function() {
|
339
|
-
ExtMVC.model.plugins = normalPlugins;
|
340
|
-
});
|
341
|
-
|
342
|
-
it("should allow specification of new plugins", function() {
|
343
|
-
var p = ExtMVC.model.plugins;
|
344
|
-
expect(p.length).to(equal, 0);
|
345
|
-
|
346
|
-
ExtMVC.model.addPlugin(myPlugin);
|
347
|
-
expect(p.length).to(equal, 1);
|
348
|
-
});
|
349
|
-
|
350
|
-
it("should call each plugin's initialize method when a model is created", function() {
|
351
|
-
initializeCalled = false;
|
352
|
-
var initializeArgument;
|
353
|
-
|
354
|
-
//set up a fake plugin initializer to check that we're receiving a reference to the model
|
355
|
-
myPlugin.initialize = function(model) {
|
356
|
-
initializeCalled = true;
|
357
|
-
initializeArgument = model;
|
358
|
-
};
|
359
|
-
|
360
|
-
ExtMVC.model.addPlugin(myPlugin);
|
361
|
-
|
362
|
-
ExtMVC.model.define('AnotherModel', {fields: []});
|
363
|
-
expect(initializeCalled).to(equal, true);
|
364
|
-
expect(initializeArgument).to(equal, ns.AnotherModel);
|
365
|
-
|
366
|
-
delete ns.AnotherModel;
|
367
|
-
});
|
368
|
-
});
|
369
|
-
});
|
370
|
-
});
|
data/lib/src/spec/OS.spec.js
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
Screw.Unit(function() {
|
2
|
-
var os;
|
3
|
-
before(function() {
|
4
|
-
os = new ExtMVC.OS();
|
5
|
-
});
|
6
|
-
|
7
|
-
describe("An OS", function() {
|
8
|
-
|
9
|
-
it("should register controllers", function() {
|
10
|
-
expect(os.getController('index')).to(equal, null);
|
11
|
-
|
12
|
-
os.registerController('index', MVCTest.controllers.IndexController);
|
13
|
-
expect(os.controllers['index']).to(equal, MVCTest.controllers.IndexController);
|
14
|
-
});
|
15
|
-
|
16
|
-
it("should find and instantiate registered controllers", function() {
|
17
|
-
os.registerController('index', MVCTest.controllers.IndexController);
|
18
|
-
expect(os.getController('index') instanceof MVCTest.controllers.IndexController).to(equal, true);
|
19
|
-
});
|
20
|
-
|
21
|
-
describe("when Launching", function() {
|
22
|
-
it("should call onLaunch", function() {
|
23
|
-
var called = false;
|
24
|
-
os.onLaunch = function() {called = true;};
|
25
|
-
|
26
|
-
os.launch();
|
27
|
-
|
28
|
-
expect(called).to(equal, true);
|
29
|
-
});
|
30
|
-
});
|
31
|
-
|
32
|
-
describe("when creating the Router", function() {
|
33
|
-
it("should not overwrite the current router", function() {
|
34
|
-
os.router = 'not a real router';
|
35
|
-
os.initializeRouter();
|
36
|
-
expect(os.router).to(equal, 'not a real router');
|
37
|
-
});
|
38
|
-
|
39
|
-
it("should assign a new Router instance to this.router", function() {
|
40
|
-
os.initializeRouter();
|
41
|
-
expect(os.router instanceof ExtMVC.Router).to(equal, true);
|
42
|
-
});
|
43
|
-
});
|
44
|
-
|
45
|
-
describe("when Dispatching", function() {
|
46
|
-
var dispatchConfig = {controller: 'someController', action: 'new'};
|
47
|
-
|
48
|
-
it("should assign dispatchConfig to os.params", function() {
|
49
|
-
os.dispatch(dispatchConfig);
|
50
|
-
expect(os.params).to(equal, dispatchConfig);
|
51
|
-
});
|
52
|
-
|
53
|
-
it("should use index as the default action", function() {
|
54
|
-
os.dispatch({controller: 'someController'});
|
55
|
-
expect(os.params).to(equal, {controller: 'someController', action: 'index'});
|
56
|
-
});
|
57
|
-
|
58
|
-
it("should attempt to find the correct controller", function() {
|
59
|
-
var controllerName = "";
|
60
|
-
|
61
|
-
var correctResponse = os.getController('index');
|
62
|
-
os.getController = function(conName) {
|
63
|
-
controllerName = conName;
|
64
|
-
return correctResponse;
|
65
|
-
};
|
66
|
-
|
67
|
-
os.dispatch({controller: 'index'});
|
68
|
-
expect(controllerName).to(equal, "index");
|
69
|
-
});
|
70
|
-
|
71
|
-
it("should fire the correct action", function() {
|
72
|
-
var fired = false;
|
73
|
-
|
74
|
-
os.getController('index').registerAction('test', function() {
|
75
|
-
fired = true;
|
76
|
-
});
|
77
|
-
|
78
|
-
os.dispatch({controller: 'index', action: 'test'});
|
79
|
-
expect(fired).to(equal, true);
|
80
|
-
});
|
81
|
-
});
|
82
|
-
});
|
83
|
-
});
|