Skip to content

Fix toggle award emoji mutation for group level work items

Mario Celi requested to merge 426474-award-emoji-mutation into master

What does this MR do and why?

Small change to group policy to enable :award_emoji on group level issues/work_items. Same min access level as those that belong to projects

Changed the policy spec to use let_it_be instead of let for ActiveRecord instances so they are not all created on every spec. Change showed almost a minute of improvement in running all the specs in the file in my local env or 38s less spent in factories.

Before

Finished in 2 minutes 14.8 seconds (files took 10.53 seconds to load)
312 examples, 0 failures

Randomized with seed 4645

[TEST PROF INFO] Time spent in factories: 01:39.474 (73.15% of total time)
bundle exec rspec spec/policies/issue_policy_spec.rb  126.04s user 11.35s system 94% cpu 2:25.96 total

After

Finished in 1 minute 23.64 seconds (files took 9.92 seconds to load)
315 examples, 0 failures

Randomized with seed 15604

[TEST PROF INFO] Time spent in factories: 01:01.236 (72.12% of total time)
bundle exec rspec spec/policies/issue_policy_spec.rb  79.72s user 9.22s system 94% cpu 1:34.29 total

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 use it 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. Toggle award emoji on the newly created work item
     mutation {
       awardEmojiToggle(input:{awardableId: "<work_item_id_returned_in_previous_step>", name: "thumbsup"}) {
         errors
         toggledOn
         awardEmoji {
           emoji
           name
           user {
             username
           }
         }
       }
     }
    Before this change, you will get an error. With this change the emoji should be toggled for the work item

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

Edited by Mario Celi

Merge request reports