Optimize factory usage for ci configuration helper

What does this MR do and why?

This MR replaces create with build_stubbed in spec/presenters/ci/group_variable_presenter_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/presenters/ci/group_variable_presenter_spec.rb.

Factory Usage Optimization Results

Before optimization:

  • Factory time: 0.978s (5.46% of total time)

After optimization:

  • Factory time: 0.007s (0.05% of total time)

🚀 Improvement:

  • Factory time reduced by: 0.971s
  • Factory time percentage reduced by: 5.41%
  • Overall factory usage improvement: 99.3%

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.1962510000012117 seconds
........[TEST PROF INFO] FactoryDoctor report

Total (potentially) bad examples: 7
Total wasted time: 00:00.941

Ci::GroupVariablePresenter (./spec/presenters/ci/group_variable_presenter_spec.rb:5) (35 records created, 00:00.941)
  is expected to eq "/groups/group1/-/variables" (./spec/presenters/ci/group_variable_presenter_spec.rb:54)  5 records created, 00:00.555
  is expected to eq "GROUP_VARIABLE" (./spec/presenters/ci/group_variable_presenter_spec.rb:36)  5 records created, 00:00.073
  takes a variable and optional params (./spec/presenters/ci/group_variable_presenter_spec.rb:20)  5 records created, 00:00.063
  exposes variable (./spec/presenters/ci/group_variable_presenter_spec.rb:24)  5 records created, 00:00.063
  forwards missing methods to variable (./spec/presenters/ci/group_variable_presenter_spec.rb:28)  5 records created, 00:00.058
  is expected to eq "/groups/group6/-/variables" (./spec/presenters/ci/group_variable_presenter_spec.rb:48)  5 records created, 00:00.068
  is expected to eq "/groups/group7/-/settings/ci_cd" (./spec/presenters/ci/group_variable_presenter_spec.rb:42)  5 records created, 00:00.058




Finished in 14.38 seconds (files took 13.8 seconds to load)
8 examples, 0 failures

Randomized with seed 16615

[TEST PROF INFO] Time spent in factories: 00:00.948 (5.22% of total time)

Factory time after update

[TEST PROF INFO] Time spent in factories: 00:00.007 (0.05% of total time)

This MR also adds the missing feature category in 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.

Merge request reports

Loading