joosy 1.2.0.alpha.66 → 1.2.0.alpha.67

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a523d74a5fa8a4314ddc142838a493df197cad0
4
- data.tar.gz: 41f0dc732482e3dc076c8a9d71f139eb04a09092
3
+ metadata.gz: dbc407e588673ab084cd80005526da25fca3be3d
4
+ data.tar.gz: 0a983ab54409d053fbe6fdc35171852bc0ddc76c
5
5
  SHA512:
6
- metadata.gz: d9c267a7e7bf6a26cb8aff5d1f219f2053c203253cbcd9e21ff3bf75713e61719b06357eafe93d0f8dbab273a43c5faa09ce2e5310b542211199d7fd5d454686
7
- data.tar.gz: 60983954587c99123ba9e2434ed0a9089a7069722801f4fa6d766ffe318dff822f92d35b17ddb2929ed770e8c914315193dbf3d3991dfb845b6d806cc1333886
6
+ metadata.gz: 8ee60dfccb024011cf8ab8f3d108386d813c54253c1d69e89b5718270c9cc5e9935e393882b37bd48628e42ae7c01754b4dd9e60808b687873032dbe3f8b04d2
7
+ data.tar.gz: 8b309f54f2acced3241d5e485161c4a304a99747ac8f040219d2a3c14010372bdbb1e5f49e647728a1306881eeef756f8573e0b07d8afc40ec02fa4498e82813
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joosy",
3
- "version": "1.2.0-alpha.66",
3
+ "version": "1.2.0-alpha.67",
4
4
  "main": "build/joosy.js",
5
5
  "ignore": [
6
6
  "lib",
@@ -126,7 +126,13 @@
126
126
  return Object.keys(this.data);
127
127
  };
128
128
 
129
- Base.prototype.load = function(data) {
129
+ Base.prototype.load = function(data, clear) {
130
+ if (clear == null) {
131
+ clear = false;
132
+ }
133
+ if (clear) {
134
+ this.data = {};
135
+ }
130
136
  this.__fillData(data);
131
137
  return this;
132
138
  };
@@ -401,9 +407,11 @@
401
407
  callback = options;
402
408
  options = {};
403
409
  }
404
- return this.model.__query(this.model.collectionPath(options, this.__source), 'GET', options.params, function(data) {
405
- _this.load(data);
406
- return typeof callback === "function" ? callback(data) : void 0;
410
+ return this.model.__query(this.model.collectionPath(options, this.__source), 'GET', options.params, function(error, data, xhr) {
411
+ if (data != null) {
412
+ _this.load(data);
413
+ }
414
+ return typeof callback === "function" ? callback(error, _this, data, xhr) : void 0;
407
415
  });
408
416
  };
409
417
 
@@ -437,6 +445,10 @@
437
445
  return _ref;
438
446
  }
439
447
 
448
+ REST.requestOptions = function(options) {
449
+ return this.prototype.__requestOptions = options;
450
+ };
451
+
440
452
  REST.source = function(location) {
441
453
  return this.__source = location;
442
454
  };
@@ -541,8 +553,8 @@
541
553
  }
542
554
  path += this.__entityName.pluralize();
543
555
  }
544
- if (options.from) {
545
- path += "/" + options.from;
556
+ if (options.action) {
557
+ path += "/" + options.action;
546
558
  }
547
559
  return path;
548
560
  };
@@ -554,7 +566,7 @@
554
566
  };
555
567
 
556
568
  REST.prototype.memberPath = function(ids, options) {
557
- var from, id, path;
569
+ var action, id, path;
558
570
  if (ids == null) {
559
571
  ids = [];
560
572
  }
@@ -572,13 +584,13 @@
572
584
  ids = [ids];
573
585
  }
574
586
  id = this.id() || ids.pop();
575
- from = options.from;
587
+ action = options.action;
576
588
  ids.push(this.id());
577
589
  path = this.collectionPath(ids, Object.merge(options, {
578
- from: void 0
590
+ action: void 0
579
591
  })) + ("/" + id);
580
- if (from != null) {
581
- path += "/" + from;
592
+ if (action != null) {
593
+ path += "/" + action;
582
594
  }
583
595
  return path;
584
596
  };
@@ -652,9 +664,11 @@
652
664
  if (Object.isArray(where) && where.length > 1) {
653
665
  result.__source = this.collectionPath(where);
654
666
  }
655
- this.__query(path, 'GET', options.params, function(data) {
656
- result.load(data);
657
- return typeof callback === "function" ? callback(result, data) : void 0;
667
+ this.__query(path, 'GET', options.params, function(error, data, xhr) {
668
+ if (data != null) {
669
+ result.load(data);
670
+ }
671
+ return typeof callback === "function" ? callback(error, result, data, xhr) : void 0;
658
672
  });
659
673
  return result;
660
674
  };
@@ -662,17 +676,29 @@
662
676
  REST.__query = function(path, method, params, callback) {
663
677
  var options;
664
678
  options = {
679
+ url: path,
665
680
  data: params,
666
681
  type: method,
667
682
  cache: false,
668
683
  dataType: 'json'
669
684
  };
670
685
  if (Object.isFunction(callback)) {
671
- options.success = callback;
686
+ options.success = function(data, _, xhr) {
687
+ return callback(false, data, xhr);
688
+ };
689
+ options.error = function(xhr) {
690
+ return callback(xhr);
691
+ };
672
692
  } else {
673
693
  Joosy.Module.merge(options, callback);
674
694
  }
675
- return $.ajax(path, options);
695
+ if (this.prototype.__requestOptions instanceof Function) {
696
+ this.prototype.__requestOptions(options);
697
+ } else if (this.prototype.__requestOptions) {
698
+ Joosy.Module.merge(options, this.prototype.__requestOptions);
699
+ console.log(this.prototype.__requestOptions);
700
+ }
701
+ return $.ajax(options);
676
702
  };
677
703
 
678
704
  REST.prototype.reload = function(options, callback) {
@@ -685,9 +711,11 @@
685
711
  callback = false;
686
712
  }
687
713
  _ref1 = this.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
688
- return this.constructor.__query(this.memberPath(options), 'GET', options.params, function(data) {
689
- _this.load(data);
690
- return typeof callback === "function" ? callback(_this) : void 0;
714
+ return this.constructor.__query(this.memberPath(options), 'GET', options.params, function(error, data, xhr) {
715
+ if (data != null) {
716
+ _this.load(data);
717
+ }
718
+ return typeof callback === "function" ? callback(error, _this, data, xhr) : void 0;
691
719
  });
692
720
  };
693
721
 
data/build/joosy.js CHANGED
@@ -932,6 +932,7 @@
932
932
  if (options == null) {
933
933
  options = {};
934
934
  }
935
+ this.prototype.__view = template;
935
936
  return this.prototype.__renderDefault = function(locals) {
936
937
  if (locals == null) {
937
938
  locals = {};
@@ -1026,10 +1027,14 @@
1026
1027
  }
1027
1028
  return _this.renderDynamic(template, locals, parentStackPointer);
1028
1029
  },
1029
- renderInline: function(locals, template) {
1030
+ renderInline: function(locals, partial) {
1031
+ var template;
1030
1032
  if (locals == null) {
1031
1033
  locals = {};
1032
1034
  }
1035
+ template = function(params) {
1036
+ return partial.apply(params);
1037
+ };
1033
1038
  return _this.renderDynamic(template, locals, parentStackPointer);
1034
1039
  }
1035
1040
  };
data/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.66",
7
+ "version": "1.2.0-alpha.67",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "homepage": "http://joosy.ws/",
10
10
  "repository": {
@@ -190,7 +190,8 @@ class Joosy.Resources.Base extends Joosy.Module
190
190
  #
191
191
  # @return [Joosy.Resources.Base] Returns self
192
192
  #
193
- load: (data) ->
193
+ load: (data, clear=false) ->
194
+ @data = {} if clear
194
195
  @__fillData data
195
196
  return this
196
197
 
@@ -6,6 +6,9 @@
6
6
  #
7
7
  class Joosy.Resources.REST extends Joosy.Resources.Base
8
8
 
9
+ @requestOptions: (options) ->
10
+ @::__requestOptions = options
11
+
9
12
  #
10
13
  # Sets default base url for fetching and modifiing resources
11
14
  #
@@ -39,7 +42,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
39
42
  # @param [Array] args Array of parent entities. Can be a string or another REST resource.
40
43
  #
41
44
  # @example Basic usage
42
- # Comment.at(['admin', @blog, @post]).collectionPath() # => '/admin/blogs/555/posts/666/comments'
45
+ # Comment.at('admin', @blog, @post).collectionPath() # => '/admin/blogs/555/posts/666/comments'
43
46
  #
44
47
  # @note accepts both array notation (Comment.at(['admin', @blog, @post])) and args notation (Comment.at('admin', @blog, @post))
45
48
  #
@@ -56,7 +59,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
56
59
  # @param [Array] args Array of parent entities. Can be a string or another REST resource.
57
60
  #
58
61
  # @example Basic usage
59
- # Comment.build(1).at(['admin', @blog, @post]).memberPath() # => '/admin/blogs/555/posts/666/comments/1'
62
+ # Comment.build(1).at('admin', @blog, @post).memberPath() # => '/admin/blogs/555/posts/666/comments/1'
60
63
  #
61
64
  # @note accepts both array notation (comment.at(['admin', @blog, @post])) and args notation (comment.at('admin', @blog, @post))
62
65
  #
@@ -87,11 +90,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
87
90
  #
88
91
  # Builds collection path
89
92
  #
90
- # @param [Array] id IDs for interpolation for masked sources
91
- # @param [Hash] options See {Joosy.Resources.REST.find} for possible options
92
- #
93
- # @example Basic usage
94
- # Resource.collectionPath() # /resources/
93
+ # @see Joosy.Resources.REST#collectionPath
95
94
  #
96
95
  @collectionPath: (args...) ->
97
96
  @::collectionPath args...
@@ -99,7 +98,16 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
99
98
  #
100
99
  # Builds collection path
101
100
  #
102
- # @see Joosy.Resources.REST.collectionPath
101
+ # @param [Array] ids Interpolation arguments for nested objects
102
+ # @param [Object] options
103
+ # @option options [String] url Manually set URL
104
+ # @option options [String] action Action to add to the URL as a suffix
105
+ #
106
+ # @example Basic usage
107
+ # Resource.collectionPath() # /resources/
108
+ #
109
+ # @example Nested resources
110
+ # Resource.collectionPath(['admin', Resource.build 1]) # /admin/resources/1/resources
103
111
  #
104
112
  collectionPath: (ids=[], options={}) ->
105
113
  if Object.isObject(ids)
@@ -117,18 +125,14 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
117
125
  path += @constructor.__namespace__.map(String::underscore).join('/') + '/' if @constructor.__namespace__.length > 0
118
126
  path += @__entityName.pluralize()
119
127
 
120
- path += "/#{options.from}" if options.from
128
+ path += "/#{options.action}" if options.action
121
129
  path
122
130
 
123
131
 
124
132
  #
125
133
  # Builds member path based on the given id.
126
134
  #
127
- # @param [String] id ID of entity to build member path for
128
- # @param [Hash] options See {Joosy.Resources.REST.find} for possible options
129
- #
130
- # @example Basic usage
131
- # Resource.memberPath(1, from: 'foo') # /resources/1/foo
135
+ # @see Joosy.Resources.REST#memberPath
132
136
  #
133
137
  @memberPath: (args...) ->
134
138
  @::memberPath args...
@@ -136,10 +140,16 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
136
140
  #
137
141
  # Builds member path
138
142
  #
139
- # @param [Hash] options See {Joosy.Resources.REST.find} for possible options
143
+ # @param [Array] ids Interpolation arguments for nested objects
144
+ # @param [Object] options
145
+ # @option options [String] url Manually set URL
146
+ # @option options [String] action Action to add to the URL as a suffix
140
147
  #
141
148
  # @example Basic usage
142
- # resource.memberPath(from: 'foo') # /resources/1/foo
149
+ # resource.memberPath(action: 'foo') # /resources/1/foo
150
+ #
151
+ # @example Nested resources
152
+ # Resource.memberPath(['admin', Resource.build 1]) # /admin/resources/1/resources/2
143
153
  #
144
154
  memberPath: (ids=[], options={}) ->
145
155
  if Object.isObject(ids)
@@ -151,11 +161,11 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
151
161
  ids = [ids] unless Object.isArray(ids)
152
162
  id = @id() || ids.pop()
153
163
 
154
- from = options.from
164
+ action = options.action
155
165
 
156
166
  ids.push @id()
157
- path = @collectionPath(ids, Object.merge(options, from: undefined)) + "/#{id}"
158
- path += "/#{from}" if from?
167
+ path = @collectionPath(ids, Object.merge(options, action: undefined)) + "/#{id}"
168
+ path += "/#{action}" if action?
159
169
  path
160
170
 
161
171
  #
@@ -164,7 +174,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
164
174
  #
165
175
  # @param [Hash] options Options to proxy to collectionPath
166
176
  # @param [Function] callback Resulting callback
167
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
177
+ # @param [Object] callback `(error, data) -> ...`
168
178
  #
169
179
  @get: (options, callback) ->
170
180
  [options, callback] = @::__extractOptionsAndCallback(options, callback)
@@ -176,7 +186,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
176
186
  #
177
187
  # @param [Hash] options Options to proxy to collectionPath
178
188
  # @param [Function] callback Resulting callback
179
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
189
+ # @param [Object] callback `(error, data) -> ...`
180
190
  #
181
191
  @post: (options, callback) ->
182
192
  [options, callback] = @::__extractOptionsAndCallback(options, callback)
@@ -188,7 +198,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
188
198
  #
189
199
  # @param [Hash] options Options to proxy to collectionPath
190
200
  # @param [Function] callback Resulting callback
191
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
201
+ # @param [Object] callback `(error, data) -> ...`
192
202
  #
193
203
  @put: (options, callback) ->
194
204
  [options, callback] = @::__extractOptionsAndCallback(options, callback)
@@ -200,7 +210,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
200
210
  #
201
211
  # @param [Hash] options Options to proxy to collectionPath
202
212
  # @param [Function] callback Resulting callback
203
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
213
+ # @param [Object] callback `(error, data) -> ...`
204
214
  #
205
215
  @delete: (options, callback) ->
206
216
  [options, callback] = @::__extractOptionsAndCallback(options, callback)
@@ -212,7 +222,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
212
222
  #
213
223
  # @param [Hash] options Options to proxy to memberPath
214
224
  # @param [Function] callback Resulting callback
215
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
225
+ # @param [Object] callback `(error, data) -> ...`
216
226
  #
217
227
  get: (options, callback) ->
218
228
  [options, callback] = @__extractOptionsAndCallback(options, callback)
@@ -224,7 +234,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
224
234
  #
225
235
  # @param [Hash] options Options to proxy to memberPath
226
236
  # @param [Function] callback Resulting callback
227
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
237
+ # @param [Object] callback `(error, data) -> ...`
228
238
  #
229
239
  post: (options, callback) ->
230
240
  [options, callback] = @__extractOptionsAndCallback(options, callback)
@@ -236,7 +246,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
236
246
  #
237
247
  # @param [Hash] options Options to proxy to memberPath
238
248
  # @param [Function] callback Resulting callback
239
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
249
+ # @param [Object] callback `(error, data) -> ...`
240
250
  #
241
251
  put: (options, callback) ->
242
252
  [options, callback] = @__extractOptionsAndCallback(options, callback)
@@ -247,7 +257,7 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
247
257
  # Callback will get parsed JSON object as a parameter.
248
258
  #
249
259
  # @param [Hash] options Options to proxy to memberPath
250
- # @param [Function] callback Resulting callback
260
+ # @param [Function] callback `(error, data) -> ...`
251
261
  #
252
262
  delete: (options, callback) ->
253
263
  [options, callback] = @__extractOptionsAndCallback(options, callback)
@@ -261,14 +271,13 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
261
271
  # Everything else will be considered as an id string and will make resource
262
272
  # query for single instance from memberPath.
263
273
  # @param [Hash] options Path modification options
264
- # @param [Function] callback Resulting callback
265
- # (will receive retrieved Collection/Resource)
274
+ # @param [Function] callback `(error, instance, data) -> ...`
266
275
  #
267
- # @option options [String] from Adds the given string as a last path element
276
+ # @option options [String] action Adds the given string as a last path element
268
277
  # i.e. /resources/trololo
269
- # @option options [String] url Sets url for request instead of generated
278
+ # @option options [String] url Sets url for request instead of generated
270
279
  # i.e. /some/custom/url
271
- # @option options [Hash] params Passes the given params to the query
280
+ # @option options [Hash] params Passes the given params to the query
272
281
  #
273
282
  @find: (where, options={}, callback=false) ->
274
283
  [options, callback] = @::__extractOptionsAndCallback(options, callback)
@@ -285,9 +294,9 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
285
294
  if Object.isArray(where) && where.length > 1
286
295
  result.__source = @collectionPath where
287
296
 
288
- @__query path, 'GET', options.params, (data) =>
289
- result.load data
290
- callback?(result, data)
297
+ @__query path, 'GET', options.params, (error, data, xhr) =>
298
+ result.load data if data?
299
+ callback?(error, result, data, xhr)
291
300
 
292
301
  result
293
302
 
@@ -296,31 +305,39 @@ class Joosy.Resources.REST extends Joosy.Resources.Base
296
305
  #
297
306
  @__query: (path, method, params, callback) ->
298
307
  options =
308
+ url: path
299
309
  data: params
300
310
  type: method
301
311
  cache: false
302
312
  dataType: 'json'
303
313
 
304
314
  if Object.isFunction(callback)
305
- options.success = callback
315
+ options.success = (data, _, xhr) -> callback(false, data, xhr)
316
+ options.error = (xhr) -> callback(xhr)
306
317
  else
307
318
  Joosy.Module.merge options, callback
308
319
 
309
- $.ajax path, options
320
+ if @::__requestOptions instanceof Function
321
+ @::__requestOptions(options)
322
+ else if @::__requestOptions
323
+ Joosy.Module.merge options, @::__requestOptions
324
+ console.log @::__requestOptions
325
+
326
+ $.ajax options
310
327
 
311
328
  #
312
329
  # Refetches the data from backend and triggers `changed`
313
330
  #
314
331
  # @param [Hash] options See {Joosy.Resources.REST.find} for possible options
315
332
  # @param [Function] callback Resulting callback
316
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
333
+ # @param [Object] callback `(error, instance, data) -> ...`
317
334
  #
318
335
  reload: (options={}, callback=false) ->
319
336
  [options, callback] = @__extractOptionsAndCallback(options, callback)
320
337
 
321
- @constructor.__query @memberPath(options), 'GET', options.params, (data) =>
322
- @load data
323
- callback? this
338
+ @constructor.__query @memberPath(options), 'GET', options.params, (error, data, xhr) =>
339
+ @load data if data?
340
+ callback?(error, @, data, xhr)
324
341
 
325
342
  #
326
343
  # utility function for better API support for unrequired first options parameter
@@ -15,16 +15,16 @@ class Joosy.Resources.RESTCollection extends Joosy.Resources.Collection
15
15
  #
16
16
  # @param [Hash] options See {Joosy.Resources.REST.find} for possible options
17
17
  # @param [Function] callback Resulting callback
18
- # @param [Object] callback Success and Error callbacks to run `{ success: () ->, error: () -> }`
18
+ # @param [Object] callback `(error, instance, data) -> ...`
19
19
  #
20
20
  reload: (options={}, callback=false) ->
21
21
  if Object.isFunction(options)
22
22
  callback = options
23
23
  options = {}
24
24
 
25
- @model.__query @model.collectionPath(options, @__source), 'GET', options.params, (data) =>
26
- @load data
27
- callback?(data)
25
+ @model.__query @model.collectionPath(options, @__source), 'GET', options.params, (error, data, xhr) =>
26
+ @load data if data?
27
+ callback?(error, @, data, xhr)
28
28
 
29
29
  load: (args...) ->
30
30
  res = super(args...)
@@ -15,6 +15,7 @@ Joosy.Modules.Renderer =
15
15
  #
16
16
  included: ->
17
17
  @view = (template, options={}) ->
18
+ @::__view = template
18
19
  @::__renderDefault = (locals={}) ->
19
20
  if options.dynamic
20
21
  @renderDynamic template, locals
@@ -98,7 +99,8 @@ Joosy.Modules.Renderer =
98
99
  @render template, locals, parentStackPointer
99
100
  renderDynamic: (template, locals={}) =>
100
101
  @renderDynamic template, locals, parentStackPointer
101
- renderInline: (locals={}, template) =>
102
+ renderInline: (locals={}, partial) =>
103
+ template = (params) -> partial.apply(params)
102
104
  @renderDynamic template, locals, parentStackPointer
103
105
 
104
106
  #
@@ -130,7 +130,7 @@ describe "Joosy.Form", ->
130
130
 
131
131
  it "should fill form with extended action", ->
132
132
  @nudeForm.fill @resource,
133
- action: @resource.memberPath(from: 'calculate')
133
+ action: @resource.memberPath(action: 'calculate')
134
134
  expect(@nudeForm.$fields()[0].value).toEqual 'foo'
135
135
  expect(@nudeForm.$fields()[1].value).toEqual 'bar'
136
136
  expect(@nudeForm.$container.attr 'action').toEqual '/tests/1/calculate'
@@ -138,7 +138,7 @@ describe "Joosy.Form", ->
138
138
  resource = @Test.build 'someId'
139
139
 
140
140
  @nudeForm.fill resource,
141
- action: resource.memberPath(from: 'calculate')
141
+ action: resource.memberPath(action: 'calculate')
142
142
  expect(@nudeForm.$container.attr 'action').toEqual '/tests/someId/calculate'
143
143
 
144
144
  it "should handle field name properly", ->
@@ -21,7 +21,7 @@ describe "Joosy.Resources.RESTCollection", ->
21
21
 
22
22
  it "reloads", ->
23
23
  @collection.load [{"id": 1, "name": "test1"}, {"id": 2, "name": "test2"}]
24
- @collection.reload from: 'test'
24
+ @collection.reload action: 'test'
25
25
 
26
26
  target = @server.requests.last()
27
27
  expect(target.method).toEqual 'GET'
@@ -95,8 +95,8 @@ describe "Joosy.Resources.REST", ->
95
95
  it 'builds member path', ->
96
96
  expect(Fluffy.memberPath 1).toEqual '/fluffies/1'
97
97
 
98
- it 'builds member path with from', ->
99
- expect(Fluffy.memberPath 1, from: 'test').toEqual '/fluffies/1/test'
98
+ it 'builds member path with action', ->
99
+ expect(Fluffy.memberPath 1, action: 'test').toEqual '/fluffies/1/test'
100
100
 
101
101
  describe 'with interpolation', ->
102
102
  it 'builds member path', ->
@@ -116,8 +116,8 @@ describe "Joosy.Resources.REST", ->
116
116
  it 'builds collection path', ->
117
117
  expect(Fluffy.collectionPath()).toEqual '/fluffies'
118
118
 
119
- it 'builds collection path with from', ->
120
- expect(Fluffy.collectionPath from: 'test').toEqual '/fluffies/test'
119
+ it 'builds collection path with action', ->
120
+ expect(Fluffy.collectionPath action: 'test').toEqual '/fluffies/test'
121
121
 
122
122
  describe 'with interpolation', ->
123
123
  it 'builds collection path', ->
@@ -128,7 +128,7 @@ describe "Joosy.Resources.REST", ->
128
128
  rawData = '{"fluffy": {"id": 1, "name": "test1"}}'
129
129
 
130
130
  beforeEach ->
131
- @callback = sinon.spy (target, data) ->
131
+ @callback = sinon.spy (error, target, data) ->
132
132
  expect(target instanceof Fluffy).toEqual true
133
133
  expect(target.id()).toEqual 1
134
134
  expect(target 'name').toEqual 'test1'
@@ -139,8 +139,8 @@ describe "Joosy.Resources.REST", ->
139
139
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\/1\?_=\d+/, rawData
140
140
  expect(@callback.callCount).toEqual 1
141
141
 
142
- it "gets item with from", ->
143
- resource = Fluffy.find 1, {from: 'action'}, @callback
142
+ it "gets item with action", ->
143
+ resource = Fluffy.find 1, {action: 'action'}, @callback
144
144
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\/1\/action\?_=\d+/, rawData
145
145
  expect(@callback.callCount).toEqual 1
146
146
 
@@ -155,7 +155,7 @@ describe "Joosy.Resources.REST", ->
155
155
  expect(@callback.callCount).toEqual 1
156
156
 
157
157
  it "gets item with direct assignation", ->
158
- resource = Fluffy.find 1, (cbResource) ->
158
+ resource = Fluffy.find 1, (error, cbResource) ->
159
159
  expect(resource).toBe cbResource
160
160
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\/1\?_=\d+/, rawData
161
161
 
@@ -163,7 +163,7 @@ describe "Joosy.Resources.REST", ->
163
163
  rawData = '{"page": 42, "fluffies": [{"id": 1, "name": "test1"}, {"id": 2, "name": "test2"}]}'
164
164
 
165
165
  beforeEach ->
166
- @callback = sinon.spy (target, data) ->
166
+ @callback = sinon.spy (error, target, data) ->
167
167
  expect(target instanceof Joosy.Resources.RESTCollection).toEqual true
168
168
  expect(target.size()).toEqual 2
169
169
  expect(target.at(0) instanceof Fluffy).toEqual true
@@ -174,8 +174,8 @@ describe "Joosy.Resources.REST", ->
174
174
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\?_=\d+/, rawData
175
175
  expect(@callback.callCount).toEqual 1
176
176
 
177
- it "gets collection with from", ->
178
- resource = Fluffy.find 'all', {from: 'action'}, @callback
177
+ it "gets collection with action", ->
178
+ resource = Fluffy.find 'all', {action: 'action'}, @callback
179
179
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\/action\?_=\d+/, rawData
180
180
  expect(@callback.callCount).toEqual 1
181
181
 
@@ -203,14 +203,14 @@ describe "Joosy.Resources.REST", ->
203
203
 
204
204
  describe "requests", ->
205
205
  rawData = '{"foo": "bar"}'
206
- callback = sinon.spy (data) ->
206
+ callback = sinon.spy (error, data) ->
207
207
  expect(data).toEqual {foo: 'bar'}
208
208
 
209
209
  describe "member", ->
210
210
  resource = Fluffy.build 1
211
211
 
212
212
  it "with get", ->
213
- resource.get {from: 'foo', params: {foo: 'bar'}}, callback
213
+ resource.get {action: 'foo', params: {foo: 'bar'}}, callback
214
214
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\/1\/foo\?foo=bar&_=\d+/, rawData
215
215
 
216
216
  it "with post", ->
@@ -229,7 +229,7 @@ describe "Joosy.Resources.REST", ->
229
229
  resource = Fluffy
230
230
 
231
231
  it "with get", ->
232
- resource.get {from: 'foo', params: {foo: 'bar'}}, callback
232
+ resource.get {action: 'foo', params: {foo: 'bar'}}, callback
233
233
  checkAndRespond @server.requests[0], 'GET', /^\/fluffies\/foo\?foo=bar&_=\d+/, rawData
234
234
 
235
235
  it "with post", ->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joosy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.alpha.66
4
+ version: 1.2.0.alpha.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Staal
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-27 00:00:00.000000000 Z
13
+ date: 2013-08-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sprockets
@@ -168,3 +168,4 @@ signing_key:
168
168
  specification_version: 4
169
169
  summary: Joosy Framework
170
170
  test_files: []
171
+ has_rdoc: