angularjs-rails-resource 1.2.2 → 1.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64bc74995e3dbdc9aad130c99d334d924338a198
4
- data.tar.gz: 12b2abe8d96b3332d843bb6eaa07b2d917ec955e
3
+ metadata.gz: 3e4a5ba390211f28af5390dfedb8b0e74a3f57b3
4
+ data.tar.gz: 9b730394170c778a38f7101b03e76b599dc4e9c6
5
5
  SHA512:
6
- metadata.gz: 74b693dacca56b514586bf3e6492917fad7b50fedbf791246ca1f0a82951f068e405b11c04c621ff672defdc8bcdceaa44bd69f0e56c81c1a3929dbb35d2561c
7
- data.tar.gz: 959b6166d3056f4c851f9fde9d1116d744550988627ea3c9eb144d25cdc76e8f9bda4521e07f4dc4bd06977cfc24dcc8a25487fca931d9f28c267ba20b95179a
6
+ metadata.gz: 0a699355c35b80febbb396c0908597ccc2426bc340b6396d60638f70ad9aa54e19e243897d5eb829d5909be57c6a8f6ec1e4e4748f5ec38cae963c414f0e1cef
7
+ data.tar.gz: fcb9f1ecae719beb565e67c85d5dbaf13cb01cf166efa4386d771e287077ca100af3f3a36d30ba615e89557caa61075ff267e2a5c1da377430085649d240f44b
@@ -1,4 +1,9 @@
1
- <a name="1.2.1"></a>
1
+ <a name="1.2.3"></a>
2
+ # 1.2.3
3
+ ## Bug Fixes
4
+ - Apply custom serialization attributes before doing full serialization - #148 (@envek)
5
+
6
+ <a name="1.2.2"></a>
2
7
  # 1.2.2
3
8
  ## Bug Fixes
4
9
  - Add support for adding custom attributes when serializing arrays - #143 (@shuhei)
data/README.md CHANGED
@@ -35,7 +35,7 @@ angular.module('app').config(["railsSerializerProvider", function(railsSerialize
35
35
  ### Rails Asset Pipeline
36
36
  Add this line to your application's Gemfile to use the latest stable version:
37
37
  ```ruby
38
- gem 'angularjs-rails-resource', '~> 1.1.1'
38
+ gem 'angularjs-rails-resource', '~> 1.2.3'
39
39
  ```
40
40
 
41
41
  Include the javascript somewhere in your asset pipeline:
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angularjs-rails-resource",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "main": "angularjs-rails-resource.js",
5
5
  "description": "A resource factory inspired by $resource from AngularJS",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  module Angularjs
2
2
  module Rails
3
3
  module Resource
4
- VERSION = '1.2.2'
4
+ VERSION = '1.2.3'
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "angularjs-rails-resource",
3
3
  "description" : "A resource factory inspired by $resource from AngularJS",
4
- "version": "1.2.2",
4
+ "version": "1.2.3",
5
5
  "main" : "dist/angularjs-rails-resource.min.js",
6
6
  "homepage" : "https://github.com/FineLinePrototyping/angularjs-rails-resource.git",
7
7
  "author" : "",
@@ -453,5 +453,67 @@ describe('railsSerializer', function () {
453
453
  expect(result).toEqual({ id: 1, books: [book]});
454
454
  });
455
455
  });
456
+
457
+ describe('nested resource collection serialization', function () {
458
+ module('rails');
459
+
460
+ angular.module('rails').factory('Team', function (railsResourceFactory, railsSerializer) {
461
+ return railsResourceFactory({
462
+ name: 'team',
463
+ serializer: railsSerializer(function() {
464
+ this.nestedAttribute('members');
465
+ this.resource('members', 'Member');
466
+ this.add('vehicle_id', function(team) {
467
+ return team.vehicle.id;
468
+ });
469
+ this.exclude('vehicle');
470
+ })
471
+ });
472
+ });
473
+ angular.module('rails').factory('Member', function (railsResourceFactory, railsSerializer) {
474
+ return railsResourceFactory({
475
+ name: 'member',
476
+ serializer: railsSerializer(function() {
477
+ this.resource('user', 'User');
478
+ this.resource('slot', 'Slot');
479
+ this.add('user_id', function(member) {
480
+ return member.user.id;
481
+ });
482
+ this.add('slot_id', function(member) {
483
+ return member.slot.id;
484
+ });
485
+ this.exclude('user', 'slot');
486
+ })
487
+ });
488
+ });
489
+ angular.module('rails').factory('Slot', function (railsResourceFactory) {
490
+ return railsResourceFactory({name: 'slot'});
491
+ });
492
+ angular.module('rails').factory('User', function (railsResourceFactory) {
493
+ return railsResourceFactory({name: 'user'});
494
+ });
495
+ angular.module('rails').factory('Vehicle', function (railsResourceFactory) {
496
+ return railsResourceFactory({name: 'vehicle'});
497
+ });
498
+
499
+
500
+ it('should add custom attribute in nested resource', inject(function(Team) {
501
+ var team1 = new Team({
502
+ id: 1,
503
+ name: 'Team 1',
504
+ vehicle: { id: 123, name: 'Subaru Impreza' },
505
+ members: [
506
+ { id: 352435, user: { id: 100500, name: 'Andrey' }, slot: { id: 200425, rank_id: 1 } },
507
+ { id: 235433, user: { id: 100501, name: 'Anton' }, slot: { id: 200426, rank_id: 2 } },
508
+ ],
509
+ });
510
+ var serializedTeam1 = {
511
+ id: 1, name: 'Team 1', vehicle_id: 123,
512
+ members_attributes: [{id: 352435, user_id: 100500, slot_id: 200425}, {id: 235433, user_id: 100501, slot_id: 200426}],
513
+ };
514
+
515
+ expect(Team.config.serializer.serialize(team1)).toEqual(serializedTeam1);
516
+ }));
517
+ });
456
518
  });
457
519
  });
@@ -411,7 +411,7 @@
411
411
  * @returns {*} A new object or array that is ready for JSON serialization
412
412
  */
413
413
  Serializer.prototype.serialize = function (data) {
414
- var result = this.serializeValue(data),
414
+ var result = angular.copy(data),
415
415
  self = this;
416
416
 
417
417
  if (angular.isObject(result)) {
@@ -435,6 +435,8 @@
435
435
  });
436
436
  }
437
437
 
438
+ result = this.serializeValue(result);
439
+
438
440
  return result;
439
441
  };
440
442
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angularjs-rails-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Odom
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-07 00:00:00.000000000 Z
12
+ date: 2015-02-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A small AngularJS add-on for integrating with Rails via JSON more easily.
15
15
  email:
@@ -19,8 +19,8 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
- - .gitignore
23
- - .travis.yml
22
+ - ".gitignore"
23
+ - ".travis.yml"
24
24
  - CHANGELOG.md
25
25
  - EXAMPLES.md
26
26
  - Gemfile
@@ -71,17 +71,17 @@ require_paths:
71
71
  - lib
72
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.1.9
84
+ rubygems_version: 2.2.2
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: AngularJS add-on resource add-on for integrating with Rails