Skip to content

Test each render method of the JSON views template namespace through a view - #17304

Merged
matrei merged 2 commits into
7.0.xfrom
test/gson-template-renderer-views
Dec 5, 2026
Merged

matrei merged 2 commits into
7.0.xfrom
test/gson-template-renderer-views

Conversation

@matrei

@matrei matrei commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #17254, from the review of #17233 on 9.0.x. Test-only.

The TemplateRendererSpec feature that #17254 added renders its views with a TemplateBook that has only a title. So a row that passes includes: ['title'] writes the same JSON with the includes dropped, and doesn't show that tmpl.render and tmpl.inline pass them on. TemplateBook gets a second property, pages, and each row states its expected JSON.

A new feature renders statically compiled views that call tmpl.render with a template (the module's grails-app/views/_child.gson), with an object, and with an object and its includes. With the feature for the customizer closures, each of the five render methods of the template namespace is now called from a view.

Verification

On this branch, with Groovy 4.0.33:

  • :grails-views-gson:check passes, with 184 tests and no failures.
  • :grails-views-gson:codeStyle finds no Checkstyle or CodeNarc violations.
  • With forwarders in TemplateRenderer that drop the map of render(Object, Map), render(Object, Map, Closure) and inline(Object, Map, Closure), exactly the four rows with includes fail.

Merging

TemplateRendererSpec is 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 with val. Whichever of the two reaches 9.0.x second conflicts in TemplateRendererSpec: keep the version with val.

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.
@matrei matrei added the run ci label Dec 3, 2026
@matrei
matrei marked this pull request as ready for review December 3, 2026 12:42
@jdaugherty

Copy link
Copy Markdown
Contributor

@matrei I think you created this while I was still merging up from 7.0.x. 7fa74e0 fixes the compile issue you're seeing on this PR. Cause: #17072 and #17073 both touched addOrderPossiblyNested and merged without a textual conflict.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good.

Brings in 7fa74e0, which compiles grails-data-hibernate5 again; the tests of grails-views-gson use it.
@matrei

matrei commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Right, I branched from 0b73627 before 7fa74e0 landed. I've merged 7.0.x into the branch (f271f5c), so CI now builds with your fix. :grails-views-gson:check still passes locally, with 184 tests.

@testlens-app

testlens-app Bot commented Dec 3, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: f271f5c
▶️ Tests: 61550 executed
⚪️ Checks: 58/58 completed


Learn more about TestLens at testlens.app/docs.

@sbglasius sbglasius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jdaugherty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@matrei
matrei merged commit f32f71b into 7.0.x Dec 5, 2026
59 checks passed
@matrei
matrei deleted the test/gson-template-renderer-views branch December 5, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants