Update PushRulesController and some specs to use an explicit organization rather than the first organization
What does this MR do and why?
- Migrate from usage of
Organizations::Organization.firstinAdmin::PushRulesControllertoCurrent.organization. - Change some usages of
Organizations::Organization.firstto use a specific organization in specs - Assigned an organization to a user to some specs after updating
spec/support/helpers/api_helpers.rb
This is all part of an effort to migrate away from assigning the 'first' organization as a fallback, and be more deliberate about which organization we want to assign it to.
| SQL | Explain query | |
|---|---|---|
| Insert | INSERT INTO "push_rules" ( "commit_message_regex", "deny_delete_tag", "created_at", "updated_at", "author_email_regex", "member_check", "file_name_regex", "is_sample", "prevent_secrets", "branch_name_regex", "reject_unsigned_commits", "commit_committer_check", "reject_non_dco_commits", "commit_committer_name_check", "organization_id" ) VALUES ('any', true, '2025-05-30 11:08:40.805474', '2025-05-30 11:08:40.805474', 'any', true, 'any', true, true, 'any', true, true, true, true, 1) returning "id" |
Postgres.ai explain |
| Update | UPDATE "push_rules" SET "commit_message_regex" = 'any', "deny_delete_tag" = true, "updated_at" = '2025-05-30 11:29:12.595701', "author_email_regex" = 'any', "member_check" = true, "file_name_regex" = 'any', "prevent_secrets" = true, "branch_name_regex" = 'any', "reject_unsigned_commits" = true, "commit_committer_check" = true, "reject_non_dco_commits" = true, "commit_committer_name_check" = true WHERE "push_rules"."id" = 25 |
Postgres.ai explain |
I haven't changed anything in terms of the SQL generated, only changed the value of the organization_id key.
References
Relates to #535463
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by tim mccarthy