Allow guest user seat assignment
What does this MR do and why?
Allow guest user seat assignment
With requirement change, we will allow seat assignment to guest users.
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"
user = User.last.to_global_id.to_s # "gid://gitlab/User/85"
namespace.add_guest(user) # add the user as guest
# 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 query and variables
mutation {
userAddOnAssignmentCreate(
input: {
userId: "gid://gitlab/User/85",
addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9",
}) {
errors
addOnPurchase {
id
purchasedQuantity
assignedQuantity
}
}
}
- Check that response has no errors
errors: []
- If we switch the branch to
master
and try to assign another guest user, it will show:"errors": ["INVALID_USER_MEMBERSHIP"]
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.
Edited by Bishwa Hang Rai