Describe in detail what your merge request does and why.
This PR adds in the migration to add project automation bots to existing projects which don't have an automation bot. The namespace_bot model has also been updated to remove a circular dependency and to remove any memberships with the namespace and user as attributes. Also, a method was added to project_namespace to get the automation bot for the project
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other pull requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Verify migration works:
On the main branch reset the db bin/rails db:drop db:create db:migrate and then seed the db bin/rails db:seed
Open up rails console and verify that Project.first.namespace.users has a user with a user_type of project_automation_bot
Get the user from step 2 with `user = Project.first.namespace.users.find_by(user_type: Users.user_types[:project_automation_bot])
Run user.destroy. This should remove the user, any personal access tokens, any memberships, and any namespace bot records
Switch over to this branch
Run bin/rails db:migrate in the terminal
Verify the migration is successful
In the rails console run Project.first.namespace.users. Verify a automation bot was added with a user_type of project_automation_bot
Verify a NamespaceBot entry was not made for the automation bot. Do this for any other projects as well and none of them should have a NamespaceBot entry
Verify a Member entry exists for the Namespace and the User(automation bot from step 8)
Verify tests pass
Verify deletion
If deleting a namespace bot, automation/regular bot(from the Users table)
1) Create a new project
2) Create an n number of new bot accounts
3) Verify in the terminal the project has n bot accounts with project.namespace.bots and only 1 namespace bot entry project.namespace.namespace_bots
4) In the terminal, delete the user from one of these bot accounts (non automation bot)
5) Verify the user, its personal access tokens, memberships, and namespace bot records are also destroyed
6) In the terminal, delete the NamespaceBot record for one of the bot accounts
7) Verify the namespace bot, and member records are deleted, and verify the user has not been deleted nor its personal access tokens
PR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
What does this PR do and why?
Describe in detail what your merge request does and why.
This PR adds in the migration to add project automation bots to existing projects which don't have an automation bot. The namespace_bot model has also been updated to remove a circular dependency and to remove any memberships with the namespace and user as attributes. Also, a method was added to project_namespace to get the automation bot for the project
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other pull requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Verify migration works:
bin/rails db:drop db:create db:migrate
and then seed the dbbin/rails db:seed
Project.first.namespace.users
has a user with a user_type ofproject_automation_bot
user.destroy
. This should remove the user, any personal access tokens, any memberships, and any namespace bot recordsbin/rails db:migrate
in the terminalProject.first.namespace.users
. Verify a automation bot was added with a user_type ofproject_automation_bot
NamespaceBot
entry was not made for the automation bot. Do this for any other projects as well and none of them should have a NamespaceBot entryMember
entry exists for the Namespace and the User(automation bot from step 8)Verify deletion
If deleting a namespace bot, automation/regular bot(from the Users table)
1) Create a new project 2) Create an
n
number of new bot accounts 3) Verify in the terminal the project hasn
bot accounts withproject.namespace.bots
and only 1 namespace bot entryproject.namespace.namespace_bots
4) In the terminal, delete the user from one of these bot accounts (non automation bot) 5) Verify the user, its personal access tokens, memberships, and namespace bot records are also destroyed 6) In the terminal, delete the NamespaceBot record for one of the bot accounts 7) Verify the namespace bot, and member records are deleted, and verify the user has not been deleted nor its personal access tokensPR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.