Skip to content

Fix `todoCreate` mutation for group level issues/work_items

Mario Celi requested to merge 426466-issue-readable-by-namespace-level into master

What does this MR do and why?

Now that an issue can belong directly to a group, readable_by? needs to be able to handle this.

No change to the authorization logic, so policy remains in sync with the method, including the abilities a user might have for a group level issue.

We had no unit specs for this method, so I added as much as I could without creating several projects. Perhaps we can add what's missing as a follow up since the new coverage is already an improvement and definitively covers group level issues which is the addition.

We also needed to update the TodoService to handle issues/work_items that don't belong to a project but directly to a group

How to set up and validate locally

  1. Enable the feature flag in Rails console Feature.enable(:namespace_level_work_items)
  2. Create a group level work item with the following query at http://127.0.0.1:3000/-/graphql-explorer so you can fetch a work item in the next query
    mutation {
       workItemCreate(input: {namespacePath: "flightjs", title: "test group level work item", workItemTypeId: "gid://gitlab/WorkItems::Type/1"}) {
         errors
         workItem {
           id
           iid
         }
       }
     }
  3. Fetch a wok item by IID and request the WorkItemWidgetLinkedItems field
     mutation {
       todoCreate(input: {targetId: "<id_returned_in_previous_step>"}) {
         errors
         todo {
           action
           author { username }
           target {
             webUrl
           }
           targetType
         }
       }
     }
    Before this change, you will get and undefined method for nil error

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 #426466 (closed)

Edited by Pedro Pombeiro

Merge request reports

Loading