File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1293,8 +1293,8 @@ Store = Ember.Object.extend({
12931293 // _partial is an internal param used by `update`.
12941294 // If passed, it means that the data should be
12951295 // merged into the existing data, not replace it.
1296-
1297- Ember . assert ( "You must include an `id` for " + typeName + " in a hash passed to `push`" , data . id != null ) ;
1296+ Ember . assert ( "Expected an object as `data` in a call to push for " + typeName + " , but was " + data , Ember . typeOf ( data ) === 'object' ) ;
1297+ Ember . assert ( "You must include an `id` for " + typeName + " in an object passed to `push`" , data . id != null ) ;
12981298
12991299 var type = this . modelFor ( typeName ) ;
13001300
Original file line number Diff line number Diff line change @@ -316,3 +316,23 @@ test("Calling pushPayload without a type should use a model's serializer when no
316316
317317 equal ( person . get ( 'firstName' ) , "Yehuda" , "you can push raw JSON into the store" ) ;
318318} ) ;
319+
320+ test ( 'calling push without data argument as an object raises an error' , function ( ) {
321+ var invalidValues = [
322+ undefined ,
323+ null ,
324+ 1 ,
325+ 'string' ,
326+ Ember . Object . create ( ) ,
327+ Ember . Object . extend ( ) ,
328+ true
329+ ] ;
330+
331+ expect ( invalidValues . length ) ;
332+
333+ Ember . EnumerableUtils . forEach ( invalidValues , function ( invalidValue ) {
334+ throws ( function ( ) {
335+ store . push ( 'person' , invalidValue ) ;
336+ } , / o b j e c t / ) ;
337+ } ) ;
338+ } ) ;
You can’t perform that action at this time.
0 commit comments