Copilot commented on code in PR #16302:
URL: https://github.com/apache/grails-core/pull/16302#discussion_r3920052878


##########
grails-fields/src/test/groovy/grails/plugin/formfields/TemplateLookupCachingSpec.groovy:
##########
@@ -122,4 +122,38 @@ class TemplateLookupCachingSpec extends 
BuildsAccessorFactory implements Service
                1 * mockGroovyPageLocator.findTemplateByPath(_) >> 
templateResource
        }
 
+       @Issue('https://github.com/apache/grails-core/issues/16162')
+       void 'distinct accessors for the same property shape share the cache'() 
{
+               given:
+               def templateResource = new 
GroovyPageResourceScriptSource('/_fields/testBean/stringProperty/_widget.gsp', 
new ByteArrayResource('BEAN PROPERTY TEMPLATE'.getBytes('UTF-8')))
+
+               and:
+               def bean1 = new TestBean(stringProperty: 'Bart Simpson')
+               def bean2 = new TestBean(stringProperty: 'Lisa Simpson')
+               def property1 = beanPropertyAccessorFactory.accessorFor(bean1, 
'stringProperty')
+               def property2 = beanPropertyAccessorFactory.accessorFor(bean2, 
'stringProperty')

Review Comment:
   This test now depends on `TestBean` being declared as a top-level class at 
the bottom of `PlainObjectPropertyAccessorSpec.groovy`, which couples two 
otherwise independent specs and can break if that spec is refactored/removed. 
Prefer extracting `TestBean` into a dedicated shared test fixture source (e.g. 
`src/test/groovy/grails/plugin/formfields/mock/TestBean.groovy`) and importing 
it from both specs, or otherwise defining a purpose-specific fixture for this 
spec.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to