Skip to content

[Refactoring] Optimize discussion_shared_examples

What does this MR do and why?

Problem

Factories build heavy objects for each test. It's slower than using let_it_be where applicable.

Solution

Apply let_it_be and restructure the test

Screenshots or screen recordings

Before

API::Discussions
  when discussions have cross-reference system notes
    behaves like with cross-reference system notes
      returns only the note that the user should see
      avoids Git calls and N+1 SQL queries

Finished in 14.89 seconds (files took 13.58 seconds to load)
2 examples, 0 failures

After

API::Discussions
  when discussions have cross-reference system notes
    behaves like with cross-reference system notes
      returns only the note that the user should see
      avoids Git calls and N+1 SQL queries

Finished in 11.42 seconds (files took 12.65 seconds to load)
2 examples, 0 failures

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports