Hi.
An index page has a navbar with refs to the various pages of the site:
class Index extends Page {
static content = {
pageA { //..}
pageB { //..}
pageC { //..}
pageD { //..}
}
}
The site implements roles. A role allows access to one (or more) pages:
- a priviledged user has access to the entire set of pages (A-D)
- Other users get access to a subset of the pages. E.G a user may only have a link to pageB when he signs-in.
- How can I assert that content DOES NOT appear in the page, using existing content templates?
So far, I've tried:
try { pageA } catch (Throwable t) { assert t instanceof RequiredPageContentNotPresent }
, but was hoping there's a more streamlined solution.
- can I somehow iterate over content? something like:
page.content.findAll {
it.name ~== /page[A-D]/}.each {
assert page."$it" == null
}
Eventually, I'm looking to incorporate the above into a data-driven spec.
Thanks!
P.S: I was setting `required:false` on the content definitions, to see whether that does away with the exception. The above 'pageX' reference in-fact relies on another template, which then references yet-another template. In order to avoid an exception, I had to mark all the templates in the inheritance chain as non-required. I expected that once I've marked the base template as not-required, that content using it shall inherit that property.