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


##########
grails-test-examples/scaffolding/src/integrationTest/groovy/com/example/UserCommunityControllerSpec.groovy:
##########
@@ -28,7 +28,7 @@ import grails.testing.mixin.integration.Integration
 @Integration
 class UserCommunityControllerSpec extends ContainerGebSpec {
 
-    void setup() {
+    private void ensureLoggedIn() {
         to(LoginPage).login()
     }

Review Comment:
   The helper name `ensureLoggedIn()` suggests it checks current auth state, 
but it always performs a login navigation. Consider renaming to something 
explicit like `loginAsTestUser()` (or add a lightweight check before 
re-logging) to better reflect behavior and intent.



##########
grails-test-examples/scaffolding/src/integrationTest/groovy/com/example/UserControllerSpec.groovy:
##########
@@ -28,7 +28,7 @@ import grails.testing.mixin.integration.Integration
 @Integration
 class UserControllerSpec extends ContainerGebSpec {
 
-    void setup() {
+    private void ensureLoggedIn() {
         to(LoginPage).login()
     }

Review Comment:
   The helper name `ensureLoggedIn()` suggests it checks current auth state, 
but it always performs a login navigation. Consider renaming to something 
explicit like `loginAsTestUser()` (or add a lightweight check before 
re-logging) to better reflect behavior and intent.



##########
grails-test-examples/scaffolding/grails-app/domain/com/example/User.groovy:
##########
@@ -56,7 +56,7 @@ class User implements UserDetails {
 
     @Override
     Collection<? extends GrantedAuthority> getAuthorities() {
-        roles.split('').collect { new SimpleGrantedAuthority(it) }
+        roles.split(',').collect { new SimpleGrantedAuthority(it.trim()) }

Review Comment:
   `getAuthorities()` will currently create a `SimpleGrantedAuthority('')` when 
`roles` is blank (default is `roles = ''`) or contains empty entries (e.g., 
trailing comma). Consider null/blank-safe parsing that trims and filters empty 
tokens so users with no roles return an empty collection (and avoid an NPE if 
`roles` is null).
   ```suggestion
           if (!roles) {
               return Collections.emptyList()
           }
           roles
                   .split(',')
                   .collect { it.trim() }
                   .findAll { it }
                   .collect { new SimpleGrantedAuthority(it) }
   ```



-- 
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