There are multiple questions in your email, hopefully I will be able to
adress them all.

First of all, I'd suggest you indeed use required: false in your content
definitions. And if your "nested" definitions might return an empty
navigator, I'd mark them as not required. I understand that this feels
cumbersome but I found that being explicit about what is required and what
not will let you catch problems with elements missing from pages quicker.

I'm personally against catching all RequiredContentNotPresent exceptions
from nested content acesses when required: false is used but I'm open to
discussion. We could also consider making value of required for all content
configurable (there's even an issue for that, as far as I remember) but
that feels like shooting birds with a cannon in this particular usecase.

With regards to iterating over content, it will only become possible when
this issue is implemented: https://github.com/geb/issues/issues/369

Hope that helps,
Marcin

On Wed, 27 Sep 2017 at 07:19, Samuel Rossinovic <[email protected]>
wrote:

> 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.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/68013fe3-8b91-48d6-a348-4ecbb4ff5799%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/68013fe3-8b91-48d6-a348-4ecbb4ff5799%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Geb 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/CA%2B52dQQ6UXhhwwcLDQiAOFnD-wjEWHuOS55c%2BbMDx4xwff3MsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to