ember-data-source 2.0.1 → 2.1.0.beta.1

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: 99cbb3e7aeb8402514a2c16df64ff6fa3dddbdbe
4
- data.tar.gz: 0074152bef6776110c690b11c710f2989be1dc1a
3
+ metadata.gz: 42a7133babf76842ad69f869acf49924e5778386
4
+ data.tar.gz: b68ec9a80f7078159afb73ef4939ef884759ab3d
5
5
  SHA512:
6
- metadata.gz: 7572751098acad398e2e478038b22093031aa42c227e1445547902a3cb08476a3a642c15ef77076545003950c27f3a9a3cf0eede684e7d0bc41ac384047e3066
7
- data.tar.gz: e98bbfa7a24ce04ad082a26df0e616f93777b0db980ad7814cceb64e655722172b7ed639e77c2a7398a5dc149ba7537aff8bd281d05d6348e58d079cfe0148f7
6
+ metadata.gz: de202a28d55bad5e3d376bd2f34c504d34e9a4714081dfb4aa8d11a0979e7d49e63b5d59d5aeb26ea7a7eab4a0ea1fd57eaa243d6658702e98f6155bcb0f8337
7
+ data.tar.gz: 9bf21e5c777c62986a361444cf653701e9a9f38fe429633a40b0b4ac765f86174d89c872ce57bf00defffaafd914a9142dd92019aa022e57d7c625dc07c73a0c
@@ -4287,7 +4287,7 @@ define(
4287
4287
  var run = Ember.run;
4288
4288
  var Person, Dog, env, store, adapter;
4289
4289
 
4290
- module("integration/adapter/store-adapter - DS.Store and DS.Adapter integration test", {
4290
+ module("integration/adapter/store_adapter - DS.Store and DS.Adapter integration test", {
4291
4291
  setup: function () {
4292
4292
  Person = DS.Model.extend({
4293
4293
  updatedAt: DS.attr('string'),
@@ -4731,13 +4731,7 @@ define(
4731
4731
  equal(type, Person, "the type is correct");
4732
4732
 
4733
4733
  if (snapshot.attr('name').indexOf('Bro') === -1) {
4734
- return Ember.RSVP.reject(new DS.InvalidError([{
4735
- title: 'Invalid Attribute',
4736
- detail: 'common... name requires a "bro"',
4737
- source: {
4738
- pointer: '/data/attributes/name'
4739
- }
4740
- }]));
4734
+ return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a "bro"'] }));
4741
4735
  } else {
4742
4736
  return Ember.RSVP.resolve();
4743
4737
  }
@@ -4776,13 +4770,7 @@ define(
4776
4770
  test("allows errors on arbitrary properties on create", function () {
4777
4771
  adapter.createRecord = function (store, type, snapshot) {
4778
4772
  if (snapshot.attr('name').indexOf('Bro') === -1) {
4779
- return Ember.RSVP.reject(new DS.InvalidError([{
4780
- title: "Invalid Attribute",
4781
- detail: "is a generally unsavoury character",
4782
- source: {
4783
- pointer: "/data/attributes/base"
4784
- }
4785
- }]));
4773
+ return Ember.RSVP.reject(new DS.InvalidError({ base: ['is a generally unsavoury character'] }));
4786
4774
  } else {
4787
4775
  return Ember.RSVP.resolve();
4788
4776
  }
@@ -4828,13 +4816,7 @@ define(
4828
4816
  saveCount++;
4829
4817
 
4830
4818
  if (snapshot.attr('name').indexOf('Bro') === -1) {
4831
- return Ember.RSVP.reject(new DS.InvalidError([{
4832
- title: 'Invalid Attribute',
4833
- detail: 'common... name requires a "bro"',
4834
- source: {
4835
- pointer: '/data/attributes/name'
4836
- }
4837
- }]));
4819
+ return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a "bro"'] }));
4838
4820
  } else {
4839
4821
  return Ember.RSVP.resolve();
4840
4822
  }
@@ -4898,13 +4880,7 @@ define(
4898
4880
  equal(type, Person, "the type is correct");
4899
4881
 
4900
4882
  if (snapshot.attr('name').indexOf('Bro') === -1) {
4901
- return Ember.RSVP.reject(new DS.InvalidError([{
4902
- title: 'Invalid Attribute',
4903
- detail: 'common... name requires a "bro"',
4904
- source: {
4905
- pointer: '/data/attributes/name'
4906
- }
4907
- }]));
4883
+ return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a "bro"'] }));
4908
4884
  } else {
4909
4885
  return Ember.RSVP.resolve();
4910
4886
  }
@@ -4959,13 +4935,7 @@ define(
4959
4935
  };
4960
4936
  adapter.updateRecord = function (store, type, snapshot) {
4961
4937
  if (snapshot.attr('name').indexOf('Bro') === -1) {
4962
- return Ember.RSVP.reject(new DS.InvalidError([{
4963
- title: "Invalid Attribute",
4964
- detail: "is a generally unsavoury character",
4965
- source: {
4966
- pointer: "/data/attributes/base"
4967
- }
4968
- }]));
4938
+ return Ember.RSVP.reject(new DS.InvalidError({ base: ['is a generally unsavoury character'] }));
4969
4939
  } else {
4970
4940
  return Ember.RSVP.resolve();
4971
4941
  }
@@ -5027,13 +4997,7 @@ define(
5027
4997
  equal(type, Person, "the type is correct");
5028
4998
  saveCount++;
5029
4999
  if (snapshot.attr('name').indexOf('Bro') === -1) {
5030
- return Ember.RSVP.reject(new DS.InvalidError([{
5031
- title: 'Invalid Attribute',
5032
- detail: 'common... name requires a "bro"',
5033
- source: {
5034
- pointer: '/data/attributes/name'
5035
- }
5036
- }]));
5000
+ return Ember.RSVP.reject(new DS.InvalidError({ name: ['common... name requires a "bro"'] }));
5037
5001
  } else {
5038
5002
  return Ember.RSVP.resolve();
5039
5003
  }
@@ -10029,128 +9993,6 @@ define(
10029
9993
  ok(user._internalModel._relationships.has('favouriteMessage'), "Newly created record with relationships in params passed in its constructor should have relationships");
10030
9994
  });
10031
9995
  });
10032
-
10033
- test("Related link should be fetched when no local data is present", function () {
10034
- expect(3);
10035
-
10036
- Book.reopen({
10037
- author: DS.belongsTo('author', { async: true })
10038
- });
10039
-
10040
- env.adapter.findBelongsTo = function (store, snapshot, url, relationship) {
10041
- equal(url, 'author', 'url is correct');
10042
- ok(true, "The adapter's findBelongsTo method should be called");
10043
- return Ember.RSVP.resolve({ id: 1, name: 'This is author' });
10044
- };
10045
-
10046
- run(function () {
10047
- var book = env.store.push({
10048
- data: {
10049
- type: 'book',
10050
- id: '1',
10051
- relationships: {
10052
- author: {
10053
- links: {
10054
- related: 'author'
10055
- }
10056
- }
10057
- }
10058
- }
10059
- });
10060
- book.get('author').then(function (author) {
10061
- equal(author.get('name'), 'This is author', 'author name is correct');
10062
- });
10063
- });
10064
- });
10065
-
10066
- test("Local data should take precedence over related link", function () {
10067
- expect(1);
10068
-
10069
- Book.reopen({
10070
- author: DS.belongsTo('author', { async: true })
10071
- });
10072
-
10073
- env.adapter.findBelongsTo = function (store, snapshot, url, relationship) {
10074
- ok(false, "The adapter's findBelongsTo method should not be called");
10075
- };
10076
-
10077
- env.adapter.findRecord = function (store, type, id, snapshot) {
10078
- return Ember.RSVP.resolve({ id: 1, name: 'This is author' });
10079
- };
10080
-
10081
- run(function () {
10082
- var book = env.store.push({
10083
- data: {
10084
- type: 'book',
10085
- id: '1',
10086
- relationships: {
10087
- author: {
10088
- links: {
10089
- related: 'author'
10090
- },
10091
- data: { type: 'author', id: '1' }
10092
- }
10093
- }
10094
- }
10095
- });
10096
- book.get('author').then(function (author) {
10097
- equal(author.get('name'), 'This is author', 'author name is correct');
10098
- });
10099
- });
10100
- });
10101
-
10102
- test("Updated related link should take precedence over local data", function () {
10103
- expect(3);
10104
-
10105
- Book.reopen({
10106
- author: DS.belongsTo('author', { async: true })
10107
- });
10108
-
10109
- env.adapter.findBelongsTo = function (store, snapshot, url, relationship) {
10110
- equal(url, 'author-updated-link', 'url is correct');
10111
- ok(true, "The adapter's findBelongsTo method should be called");
10112
- return Ember.RSVP.resolve({ id: 1, name: 'This is author' });
10113
- };
10114
-
10115
- env.adapter.findRecord = function (store, type, id, snapshot) {
10116
- ok(false, "The adapter's findRecord method should not be called");
10117
- };
10118
-
10119
- run(function () {
10120
- var book = env.store.push({
10121
- data: {
10122
- type: 'book',
10123
- id: '1',
10124
- relationships: {
10125
- author: {
10126
- links: {
10127
- related: 'author'
10128
- },
10129
- data: { type: 'author', id: '1' }
10130
- }
10131
- }
10132
- }
10133
- });
10134
-
10135
- env.store.push({
10136
- data: {
10137
- type: 'book',
10138
- id: '1',
10139
- relationships: {
10140
- author: {
10141
- links: {
10142
- related: 'author-updated-link'
10143
- }
10144
- }
10145
- }
10146
- }
10147
- });
10148
-
10149
- book.get('author').then(function (author) {
10150
- equal(author.get('name'), 'This is author', 'author name is correct');
10151
- });
10152
- });
10153
- });
10154
9996
  }
10155
9997
  );
10156
9998
 
@@ -12382,128 +12224,6 @@ define(
12382
12224
  });
12383
12225
  });
12384
12226
  });
12385
-
12386
- test("Related link should be fetched when no local data is present", function () {
12387
- expect(3);
12388
-
12389
- Post.reopen({
12390
- comments: DS.hasMany('comment', { async: true })
12391
- });
12392
-
12393
- env.adapter.findHasMany = function (store, snapshot, url, relationship) {
12394
- equal(url, 'comments', 'url is correct');
12395
- ok(true, "The adapter's findHasMany method should be called");
12396
- return Ember.RSVP.resolve([{ id: 1, body: 'This is comment' }]);
12397
- };
12398
-
12399
- run(function () {
12400
- var post = env.store.push({
12401
- data: {
12402
- type: 'post',
12403
- id: '1',
12404
- relationships: {
12405
- comments: {
12406
- links: {
12407
- related: 'comments'
12408
- }
12409
- }
12410
- }
12411
- }
12412
- });
12413
- post.get('comments').then(function (comments) {
12414
- equal(comments.get('firstObject.body'), 'This is comment', 'comment body is correct');
12415
- });
12416
- });
12417
- });
12418
-
12419
- test("Local data should take precedence over related link", function () {
12420
- expect(1);
12421
-
12422
- Post.reopen({
12423
- comments: DS.hasMany('comment', { async: true })
12424
- });
12425
-
12426
- env.adapter.findHasMany = function (store, snapshot, url, relationship) {
12427
- ok(false, "The adapter's findHasMany method should not be called");
12428
- };
12429
-
12430
- env.adapter.findRecord = function (store, type, id, snapshot) {
12431
- return Ember.RSVP.resolve({ id: 1, body: 'This is comment' });
12432
- };
12433
-
12434
- run(function () {
12435
- var post = env.store.push({
12436
- data: {
12437
- type: 'post',
12438
- id: '1',
12439
- relationships: {
12440
- comments: {
12441
- links: {
12442
- related: 'comments'
12443
- },
12444
- data: [{ type: 'comment', id: '1' }]
12445
- }
12446
- }
12447
- }
12448
- });
12449
- post.get('comments').then(function (comments) {
12450
- equal(comments.get('firstObject.body'), 'This is comment', 'comment body is correct');
12451
- });
12452
- });
12453
- });
12454
-
12455
- test("Updated related link should take precedence over local data", function () {
12456
- expect(3);
12457
-
12458
- Post.reopen({
12459
- comments: DS.hasMany('comment', { async: true })
12460
- });
12461
-
12462
- env.adapter.findHasMany = function (store, snapshot, url, relationship) {
12463
- equal(url, 'comments-updated-link', 'url is correct');
12464
- ok(true, "The adapter's findHasMany method should be called");
12465
- return Ember.RSVP.resolve([{ id: 1, body: 'This is comment' }]);
12466
- };
12467
-
12468
- env.adapter.findRecord = function (store, type, id, snapshot) {
12469
- ok(false, "The adapter's findRecord method should not be called");
12470
- };
12471
-
12472
- run(function () {
12473
- var post = env.store.push({
12474
- data: {
12475
- type: 'post',
12476
- id: '1',
12477
- relationships: {
12478
- comments: {
12479
- links: {
12480
- related: 'comments'
12481
- },
12482
- data: [{ type: 'comment', id: '1' }]
12483
- }
12484
- }
12485
- }
12486
- });
12487
-
12488
- env.store.push({
12489
- data: {
12490
- type: 'post',
12491
- id: '1',
12492
- relationships: {
12493
- comments: {
12494
- links: {
12495
- related: 'comments-updated-link'
12496
- }
12497
- }
12498
- }
12499
- }
12500
- });
12501
-
12502
- post.get('comments').then(function (comments) {
12503
- equal(comments.get('firstObject.body'), 'This is comment', 'comment body is correct');
12504
- });
12505
- });
12506
- });
12507
12227
  }
12508
12228
  );
12509
12229
 
@@ -21731,7 +21451,7 @@ define(
21731
21451
  __exports__[name] = value;
21732
21452
  }
21733
21453
 
21734
- module("unit/adapter-errors - DS.AdapterError");
21454
+ module("unit/adapter/errors - DS.AdapterError");
21735
21455
 
21736
21456
  test("DS.AdapterError", function () {
21737
21457
  var error = new DS.AdapterError();
@@ -21794,12 +21514,18 @@ define(
21794
21514
  deepEqual(result, { name: ['error message'] });
21795
21515
  });
21796
21516
 
21797
- test("DS.InvalidError will normalize errors hash will assert", function () {
21517
+ test("DS.InvalidError will normalize errors hash with deprecation", function () {
21798
21518
  var error;
21799
21519
 
21800
- expectAssertion(function () {
21520
+ expectDeprecation(function () {
21801
21521
  error = new DS.InvalidError({ name: ['is invalid'] });
21802
21522
  }, /expects json-api formatted errors/);
21523
+
21524
+ deepEqual(error.errors, [{
21525
+ title: 'Invalid Attribute',
21526
+ detail: 'is invalid',
21527
+ source: { pointer: '/data/attributes/name' }
21528
+ }]);
21803
21529
  });
21804
21530
  }
21805
21531
  );
@@ -22915,12 +22641,23 @@ define("ember-data/tests/unit/model-test", ["exports"], function(__exports__) {
22915
22641
  equal(Object.keys(mascot.changedAttributes()).length, 0, 'after rollback attributes there are no changes');
22916
22642
  });
22917
22643
 
22644
+ function toObj(obj) {
22645
+ // https://github.com/jquery/qunit/issues/851
22646
+ var result = Object.create(null);
22647
+ for (var key in obj) {
22648
+ result[key] = obj[key];
22649
+ }
22650
+ return result;
22651
+ }
22652
+
22918
22653
  test("changedAttributes() works while the record is being saved", function () {
22919
22654
  expect(1);
22920
22655
  var cat;
22921
22656
  var adapter = DS.Adapter.extend({
22922
22657
  createRecord: function (store, model, snapshot) {
22923
- deepEqual(cat.changedAttributes(), { name: [undefined, 'Argon'], likes: [undefined, 'Cheese'] });
22658
+ deepEqual(toObj(cat.changedAttributes()), {
22659
+ name: [undefined, 'Argon'],
22660
+ likes: [undefined, 'Cheese'] });
22924
22661
  return {};
22925
22662
  }
22926
22663
  });
@@ -22947,7 +22684,7 @@ define("ember-data/tests/unit/model-test", ["exports"], function(__exports__) {
22947
22684
  var cat;
22948
22685
  var adapter = DS.Adapter.extend({
22949
22686
  updateRecord: function (store, model, snapshot) {
22950
- deepEqual(cat.changedAttributes(), { name: ['Argon', 'Helia'], likes: ['Cheese', 'Mussels'] });
22687
+ deepEqual(toObj(cat.changedAttributes()), { name: ['Argon', 'Helia'], likes: ['Cheese', 'Mussels'] });
22951
22688
  return { id: '1', type: 'mascot' };
22952
22689
  }
22953
22690
  });
@@ -24155,13 +23892,7 @@ define(
24155
23892
  updateRecord: function (store, type, snapshot) {
24156
23893
  equal(callCount, 0, "becameInvalid callback was not called until recordWasInvalid is called");
24157
23894
 
24158
- return Ember.RSVP.reject(new DS.InvalidError([{
24159
- title: "Invalid Attribute",
24160
- detail: "error",
24161
- source: {
24162
- pointer: "/data/attributes/bar"
24163
- }
24164
- }]));
23895
+ return Ember.RSVP.reject(new DS.InvalidError({ bar: 'error' }));
24165
23896
  }
24166
23897
  });
24167
23898
 
@@ -27173,21 +26904,18 @@ define(
27173
26904
  var get = Ember.get;
27174
26905
  var set = Ember.set;
27175
26906
  var resolve = Ember.RSVP.resolve;
27176
- var TestAdapter, store, person, oldFilterEnabled;
26907
+ var TestAdapter, store, person;
27177
26908
  var run = Ember.run;
27178
26909
 
27179
26910
  module("unit/store/adapter-interop - DS.Store working with a DS.Adapter", {
27180
26911
  setup: function () {
27181
26912
  TestAdapter = DS.Adapter.extend();
27182
- oldFilterEnabled = Ember.ENV.ENABLE_DS_FILTER;
27183
- Ember.ENV.ENABLE_DS_FILTER = false;
27184
26913
  },
27185
26914
  teardown: function () {
27186
26915
  run(function () {
27187
26916
  if (store) {
27188
26917
  store.destroy();
27189
26918
  }
27190
- Ember.ENV.ENABLE_DS_FILTER = oldFilterEnabled;
27191
26919
  });
27192
26920
  }
27193
26921
  });
@@ -28396,38 +28124,6 @@ define(
28396
28124
  equal(store.peekRecord('person', 1).get('name'), 'Tom');
28397
28125
  });
28398
28126
 
28399
- test("store should assert of the user tries to call store.filter", function () {
28400
- expect(1);
28401
-
28402
- var Person = DS.Model.extend({
28403
- name: DS.attr('string')
28404
- });
28405
-
28406
- store = createStore({
28407
- person: Person
28408
- });
28409
-
28410
- expectAssertion(function () {
28411
- run(function () {
28412
- store.filter('person', {});
28413
- });
28414
- }, /The filter API has been moved to a plugin/);
28415
- });
28416
-
28417
- test("Calling adapterFor with a model class should assert", function () {
28418
- var Person = DS.Model.extend({
28419
- name: DS.attr('string')
28420
- });
28421
-
28422
- store = createStore({
28423
- person: Person
28424
- });
28425
-
28426
- expectAssertion(function () {
28427
- store.adapterFor(Person);
28428
- }, /Passing classes to store.adapterFor has been removed/);
28429
- });
28430
-
28431
28127
  module("unit/store/adapter_interop - find preload deprecations", {
28432
28128
  setup: function () {
28433
28129
  var Person = DS.Model.extend({
@@ -29694,13 +29390,12 @@ define(
29694
29390
  __exports__[name] = value;
29695
29391
  }
29696
29392
 
29697
- var container, store, registry, Person;
29393
+ var container, store, registry;
29698
29394
  var run = Ember.run;
29699
29395
 
29700
29396
  module("unit/store/serializer_for - DS.Store#serializerFor", {
29701
29397
  setup: function () {
29702
- Person = DS.Model.extend({});
29703
- var env = setupStore({ person: Person });
29398
+ var env = setupStore({ person: DS.Model.extend() });
29704
29399
  store = env.store;
29705
29400
  container = store.container;
29706
29401
  registry = env.registry;
@@ -29733,12 +29428,6 @@ define(
29733
29428
  test("Calling serializerFor with a type that has not been registered and in an application that does not have an ApplicationSerializer looks up the default Ember Data serializer", function () {
29734
29429
  ok(store.serializerFor('person') instanceof DS.JSONSerializer, "serializer returned from serializerFor is an instance of DS.JSONSerializer");
29735
29430
  });
29736
-
29737
- test("Calling serializerFor with a model class should assert", function () {
29738
- expectAssertion(function () {
29739
- store.serializerFor(Person);
29740
- }, /Passing classes to store.serializerFor has been removed/);
29741
- });
29742
29431
  }
29743
29432
  );
29744
29433
 
@@ -30439,6 +30128,13 @@ QUnit.test('ember-data/lib/system/debug/debug-info.js should pass jshint', funct
30439
30128
  assert.ok(true, 'ember-data/lib/system/debug/debug-info.js should pass jshint.');
30440
30129
  });
30441
30130
 
30131
+ }
30132
+ if (!QUnit.urlParams.nojshint) {
30133
+ QUnit.module('JSHint - ember-data/lib/system');
30134
+ QUnit.test('ember-data/lib/system/empty-object.js should pass jshint', function(assert) {
30135
+ assert.ok(true, 'ember-data/lib/system/empty-object.js should pass jshint.');
30136
+ });
30137
+
30442
30138
  }
30443
30139
  if (!QUnit.urlParams.nojshint) {
30444
30140
  QUnit.module('JSHint - ember-data/lib/system');