Enqueue assignments refresh worker
What does this MR do and why?
Enqueue assignments refresh worker
Whenever the ProjectGroupLink or GroupGroupLink is destroyed, we enqueue this RefreshUserAssignmentWorker.
This is a follow up to MR: !130947 (merged)
Screenshots or screen recordings
Screen_Recording_2023-09-12_at_10.02.10
How to set up and validate locally
Please view the screen recordings above to see how to unlink invited Group.
- Check out this branch
- Create a new root group: "shared-group"
- Create another group: "shared-with-group"
- Create a project: "shared-project"
- Setup some seed records
shared_group = Namespace.find_by_name "shared-group"
shared_with_group = Namespace.find_by_name "shared-with-group"
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!(
add_on: add_on, namespace: shared_group, expires_on: 1.month.from_now, quantity: 5, purchase_xid: 'A-S0001'
)
user_1 = User.find 69 # John Doe6
user_2 = User.find 70 # John Doe7
# add user to group
shared_group.add_guest(user_1)
shared_with_group.add_guest(user_2)
# assign seat to the user
add_on_purchase.assigned_users.create(user: user_1)
add_on_purchase.assigned_users.create(user: user_2)
# enable the feature flag
Feature.enable(:hamilton_seat_management)
# check the current assigned_users count
add_on_purchase.assigned_users.count # 2
# Create a GroupGroupLink record
GroupGroupLink.create!(shared_group: shared_group, shared_with_group: shared_with_group)
- Go to Groups -> Manage -> Members -> Groups tab (http://gdk.test:3000/groups/shared-group/-/group_members?tab=groups)
- Delete the Group Invite (far right button on the row), and wait for job to process
- Check in the console that assignment for
user_2
is removed:add_on_purchase.assigned_users.count # 1
# get the project
project = Project.find_by_name "shared-project"
# create a GroupProjectLink
ProjectGroupLink.create!(project: project, group: shared_with_group)
# re-assign the seats
add_on_purchase.assigned_users.create(user: user_2)
# check the current assigned_users count
add_on_purchase.assigned_users.count # 2
- Go to Projects -> Members -> Groups tab (http://gdk.test:3000/shared-group/shared-project/-/project_members?tab=groups)
- Delete the Group Invite (far right button on the row), and wait for job to process
- Check in the console that assignment for
user_2
is removed:add_on_purchase.assigned_users.count # 1
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #415302
Edited by Bishwa Hang Rai