In Grails 2.3 and above, there is currently a concept for a resource controller. However, they do not work with concepts assertUrlMappings.
/foo (resources:"foo")
Then the url-mappings-reportfollowing appears:
Controller: foo
| GET | /foo | Action: index
| GET | /foo/create | Action: create
| POST | /foo | Action: save
| GET | /foo/${id} | Action: show
| GET | /foo/${id}/edit | Action: edit
| PUT | /foo/${id} | Action: update
| PATCH | /foo/${id} | Action: patch
| DELETE | /foo/${id} | Action: delete
However, in the following file, URLs cannot be tested:
@TestFor(UrlMappings)
@Mock(FooController)
class FooURIReverseMappingsSpec extends Specification {
def "Ensure basic mapping operations for Foo uris"() {
expect:
assertUrlMapping(url, controller: expectCtrl, action: expectAction) {
id = expectId
}
where:
url | expectCtrl | expectAction | expectId
'/foo/123'|'foo'|'show'|'123'
}
}
Then WITHOUT the default action url $ controller / $ action / $ id (which will match foo/show/123) the test will not be able to find the generated URL.
Generated Error: junit.framework.AssertionFailedError: url '/ foo / 123' does not match the mappings
Is there a way to check resource urls?
source
share