File tree 1 file changed +44
-0
lines changed
packages/ember/tests/routing
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -813,6 +813,50 @@ moduleFor(
813
813
} ) ;
814
814
}
815
815
816
+ [ '@test query params are based on actual model not on url params of lowest route only' ] (
817
+ assert
818
+ ) {
819
+ assert . expect ( 2 ) ;
820
+
821
+ this . router . map ( function ( ) {
822
+ this . route ( 'parent' , { path : '/parent/:parent_id/' } , function ( ) {
823
+ this . route ( 'child' , { path : '/child/:child_id' } ) ;
824
+ } ) ;
825
+ } ) ;
826
+
827
+ let parentCache = { } ;
828
+ let childCache = { } ;
829
+
830
+ this . add (
831
+ 'route:parent' ,
832
+ Route . extend ( {
833
+ model ( { parent_id } ) {
834
+ return parentCache [ parent_id ] || ( parentCache [ parent_id ] = { id : parent_id } ) ;
835
+ } ,
836
+ } )
837
+ ) ;
838
+
839
+ this . add (
840
+ 'route:parent.child' ,
841
+ Route . extend ( {
842
+ model ( { child_id } ) {
843
+ let parent = this . modelFor ( 'parent' ) ;
844
+ let id = `${ parent . id } :${ child_id } ` ;
845
+ return childCache [ id ] || ( childCache [ id ] = { id } ) ;
846
+ } ,
847
+ } )
848
+ ) ;
849
+
850
+ this . setSingleQPController ( 'parent.child' , 'query' , '' ) ;
851
+
852
+ return this . visitAndAssert ( '/parent/1/child/2?query=foo' ) . then ( ( ) => {
853
+ this . transitionTo ( 'parent.child' , { id : 2 } , { id : 2 } ) ;
854
+ // Since Child { id: '2:2' } != Child { id: '1:2' } we should not have the same query
855
+ // params even though the url param for the parent.child route matches.
856
+ this . assertCurrentPath ( '/parent/2/child/2' ) ;
857
+ } ) ;
858
+ }
859
+
816
860
[ '@test can opt into a replace query by specifying replace:true in the Route config hash' ] (
817
861
assert
818
862
) {
You can’t perform that action at this time.
0 commit comments