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 @@ -869,6 +869,50 @@ moduleFor(
869
869
assert . equal ( indexController . get ( 'omg' ) , 'lol' ) ;
870
870
}
871
871
872
+ [ '@test query params are based on actual model not on url params of lowest route only' ] (
873
+ assert
874
+ ) {
875
+ assert . expect ( 2 ) ;
876
+
877
+ this . router . map ( function ( ) {
878
+ this . route ( 'parent' , { path : '/parent/:parent_id/' } , function ( ) {
879
+ this . route ( 'child' , { path : '/child/:child_id' } ) ;
880
+ } ) ;
881
+ } ) ;
882
+
883
+ let parentCache = { } ;
884
+ let childCache = { } ;
885
+
886
+ this . add (
887
+ 'route:parent' ,
888
+ Route . extend ( {
889
+ model ( { parent_id } ) {
890
+ return parentCache [ parent_id ] || ( parentCache [ parent_id ] = { id : parent_id } ) ;
891
+ } ,
892
+ } )
893
+ ) ;
894
+
895
+ this . add (
896
+ 'route:parent.child' ,
897
+ Route . extend ( {
898
+ model ( { child_id } ) {
899
+ let parent = this . modelFor ( 'parent' ) ;
900
+ let id = `${ parent . id } :${ child_id } ` ;
901
+ return childCache [ id ] || ( childCache [ id ] = { id } ) ;
902
+ } ,
903
+ } )
904
+ ) ;
905
+
906
+ this . setSingleQPController ( 'parent.child' , 'query' , '' ) ;
907
+
908
+ return this . visitAndAssert ( '/parent/1/child/2?query=foo' ) . then ( ( ) => {
909
+ this . transitionTo ( 'parent.child' , { id : 2 } , { id : 2 } ) ;
910
+ // Since Child { id: '2:2' } != Child { id: '1:2' } we should not have the same query
911
+ // params even though the url param for the parent.child route matches.
912
+ this . assertCurrentPath ( '/parent/2/child/2' ) ;
913
+ } ) ;
914
+ }
915
+
872
916
async [ '@test can opt into a replace query by specifying replace:true in the Route config hash' ] (
873
917
assert
874
918
) {
You can’t perform that action at this time.
0 commit comments