@@ -23,7 +23,7 @@ moduleFor(
2323 }
2424
2525 [ '@test default store utilizes the container to acquire the model factory' ] ( assert ) {
26- assert . expect ( 4 ) ;
26+ assert . expect ( 5 ) ;
2727
2828 let Post = EmberObject . extend ( ) ;
2929 let post = { } ;
@@ -55,12 +55,34 @@ moduleFor(
5555 let owner = buildOwner ( ownerOptions ) ;
5656 setOwner ( route , owner ) ;
5757
58- assert . equal ( route . model ( { post_id : 1 } ) , post ) ;
59- assert . equal ( route . findModel ( 'post' , 1 ) , post , '#findModel returns the correct post' ) ;
58+ expectDeprecation (
59+ ( ) =>
60+ ignoreAssertion ( ( ) => {
61+ assert . equal ( route . model ( { post_id : 1 } ) , post ) ;
62+ assert . equal ( route . findModel ( 'post' , 1 ) , post , '#findModel returns the correct post' ) ;
63+ } ) ,
64+ / T h e i m p l i c i t m o d e l l o a d i n g b e h a v i o r f o r r o u t e s i s d e p r e c a t e d ./
65+ ) ;
6066
6167 runDestroy ( owner ) ;
6268 }
6369
70+ [ '@test default store can be overridden' ] ( assert ) {
71+ runDestroy ( route ) ;
72+
73+ let calledFind = false ;
74+ route = EmberRoute . extend ( {
75+ store : {
76+ find ( ) {
77+ calledFind = true ;
78+ } ,
79+ } ,
80+ } ) . create ( ) ;
81+
82+ route . store . find ( ) ;
83+ assert . true ( calledFind , 'store.find was called' ) ;
84+ }
85+
6486 [ "@test assert if 'store.find' method is not found" ] ( ) {
6587 runDestroy ( route ) ;
6688
@@ -77,21 +99,23 @@ moduleFor(
7799
78100 route = owner . lookup ( 'route:index' ) ;
79101
80- expectAssertion ( function ( ) {
81- route . findModel ( 'post' , 1 ) ;
82- } , `You used the dynamic segment \`post_id\` in your route ` +
83- `\`index\` for which Ember requires you provide a ` +
84- `data-loading implementation. Commonly, that is done by ` +
85- `adding a model hook implementation on the route ` +
86- `(\`model({post_id}) {\`) or by injecting an implemention of ` +
87- `a data store: \`@service store;\`.\n\n` +
88- `Rarely, applications may attempt to use a legacy behavior where ` +
89- `the model class (in this case \`post\`) is resolved and the ` +
90- `\`find\` method on that class is invoked to load data. In this ` +
91- `application, a model of \`post\` was found but it did not ` +
92- `provide a \`find\` method. You should not add a \`find\` ` +
93- `method to your model. Instead, please implement an appropriate ` +
94- `\`model\` hook on the \`index\` route.` ) ;
102+ ignoreDeprecation ( ( ) =>
103+ expectAssertion ( function ( ) {
104+ route . findModel ( 'post' , 1 ) ;
105+ } , `You used the dynamic segment \`post_id\` in your route ` +
106+ `\`index\` for which Ember requires you provide a ` +
107+ `data-loading implementation. Commonly, that is done by ` +
108+ `adding a model hook implementation on the route ` +
109+ `(\`model({post_id}) {\`) or by injecting an implemention of ` +
110+ `a data store: \`@service store;\`.\n\n` +
111+ `Rarely, applications may attempt to use a legacy behavior where ` +
112+ `the model class (in this case \`post\`) is resolved and the ` +
113+ `\`find\` method on that class is invoked to load data. In this ` +
114+ `application, a model of \`post\` was found but it did not ` +
115+ `provide a \`find\` method. You should not add a \`find\` ` +
116+ `method to your model. Instead, please implement an appropriate ` +
117+ `\`model\` hook on the \`index\` route.` )
118+ ) ;
95119
96120 runDestroy ( owner ) ;
97121 }
@@ -109,14 +133,16 @@ moduleFor(
109133
110134 route = owner . lookup ( 'route:index' ) ;
111135
112- expectAssertion ( function ( ) {
113- route . model ( { post_id : 1 } ) ;
114- } , `You used the dynamic segment \`post_id\` in your route ` +
115- `\`index\` for which Ember requires you provide a ` +
116- `data-loading implementation. Commonly, that is done by ` +
117- `adding a model hook implementation on the route ` +
118- `(\`model({post_id}) {\`) or by injecting an implemention of ` +
119- `a data store: \`@service store;\`.` ) ;
136+ ignoreDeprecation ( ( ) =>
137+ expectAssertion ( function ( ) {
138+ route . model ( { post_id : 1 } ) ;
139+ } , `You used the dynamic segment \`post_id\` in your route ` +
140+ `\`index\` for which Ember requires you provide a ` +
141+ `data-loading implementation. Commonly, that is done by ` +
142+ `adding a model hook implementation on the route ` +
143+ `(\`model({post_id}) {\`) or by injecting an implemention of ` +
144+ `a data store: \`@service store;\`.` )
145+ ) ;
120146
121147 runDestroy ( owner ) ;
122148 }
@@ -130,9 +156,7 @@ moduleFor(
130156
131157 route = owner . lookup ( 'route:index' ) ;
132158
133- ignoreAssertion ( function ( ) {
134- route . model ( { post_id : 1 } ) ;
135- } ) ;
159+ ignoreDeprecation ( ( ) => ignoreAssertion ( ( ) => route . model ( { post_id : 1 } ) ) ) ;
136160
137161 assert . ok ( true , 'no error was raised' ) ;
138162
0 commit comments