Fix inaccurate gitlab_employee? tests
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
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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