Repository navigation
Test each render method of the JSON views template namespace through a view - #17304
Conversation
The views of TemplateRendererSpec rendered a TemplateBook with only a title, so a row that passed includes: ['title'] wrote the same JSON when the includes were dropped. TemplateBook gets a second property, and each row states its expected JSON. A new feature renders statically compiled views that call tmpl.render with a template, with an object, and with an object and its includes. With the feature for the customizer closures, each render method of the template namespace is now called from a view.
jamesfredley
left a comment
There was a problem hiding this comment.
The changes look good.
Brings in 7fa74e0, which compiles grails-data-hibernate5 again; the tests of grails-views-gson use it.
✅ All tests passed ✅🏷️ Commit: f271f5c Learn more about TestLens at testlens.app/docs. |
sbglasius
left a comment
There was a problem hiding this comment.
Looks good. Adding pages to TemplateBook is what makes the includes rows mean something: before, dropping the includes produced the same JSON. Now every render overload of the template namespace is called from a real, statically compiled view, and each row checks the exact JSON it expects. Only the test changes, CI is green, and the earlier compile failure is gone since 7.0.x was merged in.
Optional, could be a follow-up: inline(Object) and inline(Object, Map) still aren't called from a view, and rows for them would fit in the same table.
jdaugherty
left a comment
There was a problem hiding this comment.
Re-reviewed f271f5c. Looks good. The populated pages property makes the includes assertions meaningful, and the three added view cases complete coverage of the five render overloads through the compiled JSON-view API. The child-template expectation matches _child.gson, and this changes only tests.
I also compared this spec with #17233: the only difference is final versus val in the two local declarations. All ten TemplateRendererSpec cases pass locally on that Groovy 6 branch. For this Groovy 4 branch, I checked the current green CI results rather than rerunning the suite locally. No actionable findings.
Description
Follow-up to #17254, from the review of #17233 on 9.0.x. Test-only.
The
TemplateRendererSpecfeature that #17254 added renders its views with aTemplateBookthat has only a title. So a row that passesincludes: ['title']writes the same JSON with the includes dropped, and doesn't show thattmpl.renderandtmpl.inlinepass them on.TemplateBookgets a second property,pages, and each row states its expected JSON.A new feature renders statically compiled views that call
tmpl.renderwith a template (the module'sgrails-app/views/_child.gson), with an object, and with an object and its includes. With the feature for the customizer closures, each of the fiverendermethods of the template namespace is now called from a view.Verification
On this branch, with Groovy 4.0.33:
:grails-views-gson:checkpasses, with 184 tests and no failures.:grails-views-gson:codeStylefinds no Checkstyle or CodeNarc violations.TemplateRendererthat drop the map ofrender(Object, Map),render(Object, Map, Closure)andinline(Object, Map, Closure), exactly the four rows with includes fail.Merging
TemplateRendererSpecis the same file on every branch up to 9.0.x, so the commit merges up without conflicts to 9.0.x. #17233 makes the same change there, written withval. Whichever of the two reaches 9.0.x second conflicts inTemplateRendererSpec: keep the version withval.