Skip to content

Commit

Permalink
[BUGFIX release] Fix RESTAdapter.buildQuery without a snapshot
Browse files Browse the repository at this point in the history
Before introducing a feature ds-finder-include it was possible to run
findRecord on an adapter without passing a snapshot. After introducing
the feature it's no longer possible even if the feature is disabled,
because some of the code was outsief of the flag check.

This commit fixes the code to work like before introducing the
ds-finder-include change.

(cherry picked from commit c3b6094)
  • Loading branch information
drogus authored and bmac committed Mar 18, 2016
1 parent 29d593f commit 242d198
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions addon/adapters/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,13 +992,15 @@ export default Adapter.extend(BuildURLMixin, {
},

buildQuery(snapshot) {
const { include } = snapshot;

let query = {};

if (isEnabled('ds-finder-include')) {
if (include) {
query.include = include;
if (snapshot) {
const { include } = snapshot;

if (include) {
query.include = include;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/adapters/rest-adapter/build-query-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ test("buildQuery() returns an empty query when snapshot has no query params", fu
assert.deepEqual(query, {}, 'query is empty');
});

test("buildQuery - doesn't fail without a snapshot", function(assert) {
const adapter = DS.RESTAdapter.create();
const query = adapter.buildQuery();

assert.deepEqual(query, {}, 'returns an empty query');
});

if (isEnabled('ds-finder-include')) {
test("buildQuery() returns query with `include` from snapshot", function(assert) {
const adapter = DS.RESTAdapter.create();
Expand Down

0 comments on commit 242d198

Please sign in to comment.