Add mutation userAddOnAssignmentRemove
What does this MR do and why?
Add mutation userAddOnAssignmentRemove
This MR adds new mutation to remove a user's add_on assignment corresponding to add_on_purchase.
It is dependent on: !126964 (merged) to be merged first.
Screenshots or screen recordings
Success
Error
How to set up and validate locally
- Check out the branch
- Create a new root group namespace
- Setup some seed records
namespace = Namespace.last
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: namespace, expires_on: 1.month.from_now, quantity: 5, purchase_xid: 'A-S0001'
)
add_on_purchase.to_global_id.to_s # "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9"
# create some assignments
add_on_purchase.assigned_users.create!(user: (User.find 85))
# enable the feature flag
Feature.enable(:hamilton_seat_management)
- Go to graphql explorer (logged in as owner/admin): http://gdk.test:3000/-/graphql-explorer, and use following mutation:
mutation {
userAddOnAssignmentRemove(
input: {
userId: "gid://gitlab/User/85",
addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9",
}) {
errors
}
}
- Check that response has no errors
errors: []
- Sending the same request again for assigned user will return empty response.
- Setup the seed record again if needed
- Login with a user who has only a developer role in the group.
- When trying to remove user assignment, other than self, it will return error.
- When removing self (logged in user with developer role) from assignment, it should return success.
- Update the
add_on_purchase
to expire:add_on_purchase.update!(expires_on: 1.day.ago)
. - Trying to remove any assignment will return 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #415585
Edited by Bishwa Hang Rai