Skip to content

Speed up hook spec

Bojan Marjanovic requested to merge bmarjanovic/speed-up-hooks-spec into master

What does this MR do and why?

This MR refactors spec/models/hooks/*, and more hook related specs to use let_it_be, build, build_stubbed for factories, where possible. These greatly speeds up the specs by removing redundant factory initializations.

Performance

Before

[TEST PROF INFO] Time spent in factories: 00:18.890 (47.86% of total time)
[TEST PROF INFO] Factories usage

 Total: 302
 Total top-level: 158
 Total time: 00:18.890 (out of 00:44.454)
 Total uniq factories: 12

After

[TEST PROF INFO] Time spent in factories: 00:04.026 (14.17% of total time)
[TEST PROF INFO] Factories usage

Total: 72
Total top-level: 63
Total time: 00:04.026 (out of 00:33.440)
Total uniq factories: 12

How to set up and validate locally

  1. Run spec/models/hooks/ locally
  2. Run ee/spec/models/hooks/group_hook_spec.rb locally
  3. Run spec/features/admin/admin_hooks_spec.rb locally
  4. Run spec/features/admin/admin_hook_logs_spec.rb locally

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