Skip to content

Fix canApprove GraphQL field returning null

Patrick Bajao requested to merge 416863-fix-null-can-approve into master

What does this MR do and why?

The Approvable#eligible_for_unapproval_by? can return nil when user is not present. The canApprove GraphQL field is required and not nullable though. As a result, it returns a GraphQL error as a response to GraphQL query.

To fix that, we check if user.present? instead of only user. Also updated the spec to check for true and false value to ensure that it doesn't return a nil value.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #416863 (closed)

Merge request reports