Skip to content

Commit

Permalink
Merge pull request #4116 from pangratz/add-assertions-for-query
Browse files Browse the repository at this point in the history
Add assertions for store#query()
  • Loading branch information
bmac committed Jan 27, 2016
2 parents 6188c68 + 5b84397 commit eb83d5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ Store = Service.extend({
},

_query(modelName, query, array) {
assert("You need to pass a type to the store's query method", modelName);
assert("You need to pass a query hash to the store's query method", query);
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
var typeClass = this.modelFor(modelName);
array = array || this.recordArrayManager
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/adapter/queries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ module("integration/adapter/queries - Queries", {
}
});

test("It raises an assertion when no type is passed", function(assert) {
assert.expectAssertion(function() {
store.query();
}, "You need to pass a type to the store's query method");
});

test("It raises an assertion when no query hash is passed", function(assert) {
assert.expectAssertion(function() {
store.query('person');
}, "You need to pass a query hash to the store's query method");
});

test("When a query is made, the adapter should receive a record array it can populate with the results of the query.", function(assert) {
adapter.query = function(store, type, query, recordArray) {
assert.equal(type, Person, "the query method is called with the correct type");
Expand Down

0 comments on commit eb83d5c

Please sign in to comment.