Optimize factory usage for jira connect helper
What does this MR do and why?
This MR replaces create with build_stubbed in spec/helpers/jira_connect_helper_spec.rb to optimize the factory usage as recommended in our handbook.
This spec is part of the list .rubocop_todo/rspec/factory_bot/avoid_create.yml.
It was verified that database persistence is not needed using the factory doctor command FDOC=1 bin/rspec spec/helpers/jira_connect_helper_spec.rb.
Factory Usage Optimization Results
Before optimization:
- Factory time: 1.327s (6.58% of total time)
After optimization:
- Factory time: 0.005s (0.03% of total time)
- Factory time reduced by: 1.322s
- Factory time percentage reduced by: 6.55%
- Overall factory usage improvement: 99.6%
Factory Doctor Output
[TEST PROF INFO] FactoryDoctor enabled (event: "sql.active_record", threshold: 0.01)
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
==> Using precompiled Gitaly binaries from cache
Test environment set up in 1.3507819999995263 seconds
...........[TEST PROF INFO] FactoryDoctor report
Total (potentially) bad examples: 2
Total wasted time: 00:00.299
JiraConnectHelper (./spec/helpers/jira_connect_helper_spec.rb:5) (4 records created, 00:00.299)
assigns users_path to nil (./spec/helpers/jira_connect_helper_spec.rb:120) – 2 records created, 00:00.263
assigns gitlab_user_path correctly (./spec/helpers/jira_connect_helper_spec.rb:124) – 2 records created, 00:00.035
Finished in 15.25 seconds (files took 15.66 seconds to load)
11 examples, 0 failures
[TEST PROF INFO] Time spent in factories: 00:01.106 (5.72% of total time)
Factory time after update
[TEST PROF INFO] Time spent in factories: 00:00.005 (0.03% of total time)
References
Relates to: #378910.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.