Add test coverage for confidential notes in `Notes::BuildService`
Related to #321778
What does this MR do and why?
Confidential notes are still under development and not widely available yet. See &2697
This MR focuses only on extending coverage for testing of permissions related to creating and replying to confidential notes (using Notes::BuildService
). See https://gitlab.com/gitlab-org/gitlab/-/issues/321778#note_834471080.
The user needs reporter+ permissions to be able to set a note as confidential unless it's the author of the noteable, or an assignee. In these two cases, being a member is not required but the user must be able to create notes in the noteable.
Additionally, most let
declarations are replaced with let_it_be
to reduce the number of records created:
EVENT_PROF='sql.active_record' bin/rspec ./spec/services/notes/build_service_spec.rb
Before
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:06.317 of 00:18.408 (34.32%)
Total events: 3027
After
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:03.012 of 00:13.299 (22.65%)
Total events: 1763
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.