Optimize factory usage in suggestion_entity_spec
What does this MR do and why?
This MR replaces create with build_stubbed in spec/serializers/suggestion_entity_spec.rb to optimize 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/serializers/suggestion_entity_spec.rb.
Factory Usage Optimization Results
Before optimization:
- Factory time: 6.049s (30.2% of total time)
After optimization:
- Factory time: 0.06s (0.43% of total time)
Improvement:
- Factory time reduced by: 5.989s
- Factory time percentage reduced by: 29.77%
- Overall factory usage improvement: 99.0%
Factory Doctor Output
[TEST PROF INFO] FactoryDoctor report
Total (potentially) bad examples: 2
Total wasted time: 00:01.889
SuggestionEntity (./spec/serializers/suggestion_entity_spec.rb:5) (18 records created, 00:01.889)
returns the inapplicable reason (./spec/serializers/suggestion_entity_spec.rb:42) – 9 records created, 00:01.063
returns appropriate message (./spec/serializers/suggestion_entity_spec.rb:50) – 9 records created, 00:00.825This MR also adds the missing feature_category to this spec.
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.
Edited by Marcos Rocha