Skip to content

Fix inaccurate gitlab_employee? tests

Jake Lear requested to merge jl-fix-gitlab-employee-tests into master

What does this MR do?

While working on !42905 (merged) I realized that the existing tests for gitlab_employee? didn't accurately test certain scenarios.

The method uses ::Gitlab::Com.gitlab_com_group_member_id?(id) to check if the user is a GitLab employee, but the tests use build to create the user record. Because build doesn't store a record, the user doesn't have an ID. This means that the method returns false as is expected for the test, but the reason that it returns false is not what we're trying to test.

This MR updates the tests to use create so that an ID gets created and the method can succeed to the point where the test actually expects it to fail.

Furthermore, the original test was missing a stub for Gitlab.com? which is checked in gitlab_com_group_member_id, so this MR also adds that stub.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Merge request reports

Loading