Skip to content

Commit

Permalink
Revert "chore: refactor store to class (#6249)"
Browse files Browse the repository at this point in the history
This reverts commit e356cce.
  • Loading branch information
runspired committed Jul 31, 2019
1 parent 8bc9a89 commit 9be6bfd
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 268 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/ember__debug": "^3.0.3",
"@types/ember__test-helpers": "~0.7.8",
"@types/qunit": "^2.5.3",
"@types/rsvp": "^4.0.3",
"@types/rsvp": "^4.0.2",
"babel-eslint": "^10.0.2",
"broccoli-babel-transpiler": "^7.2.0",
"broccoli-concat": "^3.7.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/-ember-data/tests/helpers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export default function setupStore(options) {
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });

const TestStore = Store.extend({ adapter });
owner.register('service:store', TestStore);
owner.register('service:store', Store.extend({ adapter }));
owner.register('serializer:-default', JSONAPISerializer);
owner.register('serializer:-json', JSONSerializer);
owner.register('serializer:-rest', RESTSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ module('integration/adapter/queries - Queries', function(hooks) {
});

testInDebug('The store asserts when query is made and the adapter responses with a single record.', function(assert) {
env = setupStore({
person: Person,
adapter: DS.RESTAdapter,
});
env = setupStore({ person: Person, adapter: DS.RESTAdapter });
store = env.store;
adapter = env.adapter;

adapter.query = function(store, type, query, recordArray) {
assert.equal(type, Person, 'the query method is called with the correct type');

return resolve({
data: { id: 1, type: 'person', attributes: { name: 'Peter Wagenet' } },
data: [{ id: 1, type: 'person', attributes: { name: 'Peter Wagenet' } }],
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ export default class InternalModel {

save(options) {
let promiseLabel = 'DS: Model#save ' + this;
let resolver = RSVP.defer<InternalModel>(promiseLabel);
let resolver = RSVP.defer(promiseLabel);

this.store.scheduleSave(this, resolver, options);
return resolver.promise;
Expand Down
9 changes: 3 additions & 6 deletions packages/store/addon/-private/system/references/record.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import RSVP, { resolve } from 'rsvp';
import Reference from './reference';
import { Record } from '../../ts-interfaces/record';
import { JsonApiResource } from '../../ts-interfaces/record-data-json-api';
import { JsonApiDocument, SingleResourceDocument } from '../../ts-interfaces/ember-data-json-api';

/**
@module @ember-data/store
Expand Down Expand Up @@ -96,10 +93,10 @@ export default class RecordReference extends Reference {
```
@method push
@param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
@return a promise for the value (record or relationship)
@param objectOrPromise {Promise|Object}
@return RSVP.Promise<record> a promise for the value (record or relationship)
*/
push(objectOrPromise: SingleResourceDocument | Promise<SingleResourceDocument>): RSVP.Promise<Record> {
push(objectOrPromise): RSVP.Promise<object> {
return resolve(objectOrPromise).then(data => {
return this.store.push(data);
});
Expand Down
Loading

0 comments on commit 9be6bfd

Please sign in to comment.