Details
Description
With the following mapping:
"/user/$idText?"{ controller = "user" action = "publicProfile" }
The following assert should fail, but it doesn't:
assertForwardUrlMapping("/user", controller: "user", action: "publicProfile") { idText = "1234" }
The problem is that the method assertForwardUrlMapping doesn't check the params assertions. I have checked it debugging the code, and I think that the problem exactly is in the line 170 of the GrailsUrlMappingsTestCase:
if(!controllers.containsKey(actual) && mappingInfos.size() > 1) return
In all the cases the code checks if the "actual" value is a controller. For the cases of actions (in my case "publicProfile") the return sentence is executed and the sentences that really check the param assertions (later in the code) are never executed.
I think that the solution is to make the check only if we are talking about a controller:
if(key == "controller" && !controllers.containsKey(actual) && mappingInfos.size() > 1) return
BTW, in the line 187 of the same file (GrailsUrlMappingsTestCase), the assertEquals compares "value.toString()" and "mapping.params[name]". When the value is null (for instance, to check that an specific param is not set) the assertion fails. I think that the solution is to compare "value.toString()" with "mapping.params[name].toString()". I changed the code, I tested it and it ran ok.
Attached a really simple test project that shows the issue. The bug is still there in 1.3.7