Skip to content

Commit

Permalink
Change "type" to "model name" in assertion messages
Browse files Browse the repository at this point in the history
  • Loading branch information
courajs committed Mar 18, 2016
1 parent f6ea6da commit cb67a75
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
34 changes: 17 additions & 17 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Store = Service.extend({
@return {DS.Model} record
*/
createRecord(modelName, inputProperties) {
assert("You need to pass a type to the store's createRecord method", isPresent(modelName));
assert("You need to pass a model name to the store's createRecord method", isPresent(modelName));
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);
var properties = copy(inputProperties) || new EmptyObject();
Expand Down Expand Up @@ -459,7 +459,7 @@ Store = Service.extend({
@return {Promise} promise
*/
findRecord(modelName, id, options) {
assert("You need to pass a type to the store's findRecord method", isPresent(modelName));
assert("You need to pass a model name to the store's findRecord method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
assert(badIdFormatAssertion, (typeof id === 'string' && id.length > 0) || (typeof id === 'number' && !isNaN(id)));

Expand Down Expand Up @@ -534,7 +534,7 @@ Store = Service.extend({
@return {Promise} promise
*/
findByIds(modelName, ids) {
assert("You need to pass a type to the store's findByIds method", isPresent(modelName));
assert("You need to pass a model name to the store's findByIds method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
let promises = new Array(ids.length);

Expand Down Expand Up @@ -725,7 +725,7 @@ Store = Service.extend({
@return {DS.Model|null} record
*/
peekRecord(modelName, id) {
assert("You need to pass a type to the store's peekRecord method", isPresent(modelName));
assert("You need to pass a model name to the store's peekRecord method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
if (this.hasRecordForId(modelName, id)) {
return this._internalModelForId(modelName, id).getRecord();
Expand Down Expand Up @@ -767,7 +767,7 @@ Store = Service.extend({
@return {Boolean}
*/
hasRecordForId(modelName, inputId) {
assert("You need to pass a type to the store's hasRecordForId method", isPresent(modelName));
assert("You need to pass a model name to the store's hasRecordForId method", isPresent(modelName));
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);
var id = coerceId(inputId);
Expand All @@ -786,7 +786,7 @@ Store = Service.extend({
@return {DS.Model} record
*/
recordForId(modelName, id) {
assert("You need to pass a type to the store's recordForId method", isPresent(modelName));
assert("You need to pass a model name to the store's recordForId method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
return this._internalModelForId(modelName, id).getRecord();
},
Expand Down Expand Up @@ -920,7 +920,7 @@ Store = Service.extend({
},

_query(modelName, query, array) {
assert("You need to pass a type to the store's query method", isPresent(modelName));
assert("You need to pass a model name to the store's query method", isPresent(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);
Expand Down Expand Up @@ -952,7 +952,7 @@ Store = Service.extend({
@return {Promise} promise
*/
queryRecord(modelName, query) {
assert("You need to pass a type to the store's queryRecord method", isPresent(modelName));
assert("You need to pass a model name to the store's queryRecord method", isPresent(modelName));
assert("You need to pass a query hash to the store's queryRecord method", query);
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');

Expand Down Expand Up @@ -988,7 +988,7 @@ Store = Service.extend({
@return {DS.AdapterPopulatedRecordArray}
*/
findAll(modelName, options) {
assert("You need to pass a type to the store's findAll method", isPresent(modelName));
assert("You need to pass a model name to the store's findAll method", isPresent(modelName));
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);

Expand Down Expand Up @@ -1058,7 +1058,7 @@ Store = Service.extend({
@return {DS.RecordArray}
*/
peekAll(modelName) {
assert("You need to pass a type to the store's peekAll method", isPresent(modelName));
assert("You need to pass a model name to the store's peekAll method", isPresent(modelName));
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);

Expand Down Expand Up @@ -1164,7 +1164,7 @@ Store = Service.extend({
@deprecated
*/
filter(modelName, query, filter) {
assert("You need to pass a type to the store's filter method", isPresent(modelName));
assert("You need to pass a model name to the store's filter method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');

if (!Ember.ENV.ENABLE_DS_FILTER) {
Expand Down Expand Up @@ -1216,7 +1216,7 @@ Store = Service.extend({
@return {boolean}
*/
recordIsLoaded(modelName, id) {
assert("You need to pass a type to the store's recordIsLoaded method", isPresent(modelName));
assert("You need to pass a model name to the store's recordIsLoaded method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
return this.hasRecordForId(modelName, id);
},
Expand Down Expand Up @@ -1473,7 +1473,7 @@ Store = Service.extend({
@return {DS.Model}
*/
modelFor(modelName) {
assert("You need to pass a type to the store's modelFor method", isPresent(modelName));
assert("You need to pass a model name to the store's modelFor method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');

var factory = this.modelFactoryFor(modelName);
Expand All @@ -1490,7 +1490,7 @@ Store = Service.extend({
},

modelFactoryFor(modelName) {
assert("You need to pass a type to the store's modelFactoryFor method", isPresent(modelName));
assert("You need to pass a model name to the store's modelFactoryFor method", isPresent(modelName));
assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of '+ Ember.inspect(modelName), typeof modelName === 'string');
var normalizedKey = normalizeModelName(modelName);

Expand Down Expand Up @@ -1814,7 +1814,7 @@ Store = Service.extend({
@return {Object} The normalized payload
*/
normalize(modelName, payload) {
assert("You need to pass a type to the store's normalize method", isPresent(modelName));
assert("You need to pass a model name to the store's normalize method", isPresent(modelName));
assert(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${Ember.inspect(modelName)}`, typeof modelName === 'string');
var serializer = this.serializerFor(modelName);
var model = this.modelFor(modelName);
Expand Down Expand Up @@ -1908,7 +1908,7 @@ Store = Service.extend({
@return DS.Adapter
*/
adapterFor(modelName) {
assert("You need to pass a type to the store's adapterFor method", isPresent(modelName));
assert("You need to pass a model name to the store's adapterFor method", isPresent(modelName));
assert(`Passing classes to store.adapterFor has been removed. Please pass a dasherized string instead of ${Ember.inspect(modelName)}`, typeof modelName === 'string');

return this.lookupAdapter(modelName);
Expand Down Expand Up @@ -1944,7 +1944,7 @@ Store = Service.extend({
@return {DS.Serializer}
*/
serializerFor(modelName) {
assert("You need to pass a type to the store's serializerFor method", isPresent(modelName));
assert("You need to pass a model name to the store's serializerFor method", isPresent(modelName));
assert(`Passing classes to store.serializerFor has been removed. Please pass a dasherized string instead of ${Ember.inspect(modelName)}`, typeof modelName === 'string');

var fallbacks = [
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/adapter/queries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ 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");
}, "You need to pass a model name to the store's query method");
});

test("It raises an assertion when no query hash is passed", function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/store/query-record-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module("integration/store/query-record - Query one record with a query hash", {
test("It raises an assertion when no type is passed", function(assert) {
assert.expectAssertion(function() {
store.queryRecord();
}, "You need to pass a type to the store's queryRecord method");
}, "You need to pass a model name to the store's queryRecord method");
});

test("It raises an assertion when no query hash is passed", function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/store/asserts-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ test("Calling Store methods with no type asserts", function(assert) {
MODEL_NAME_METHODS.forEach(function(methodName) {
assert.expectAssertion(function() {
store[methodName](null);
}, new RegExp(`You need to pass a type to the store's ${methodName} method`));
}, new RegExp(`You need to pass a model name to the store's ${methodName} method`));
});
});

0 comments on commit cb67a75

Please sign in to comment.