Clean up MergeTrains::Train specs
What does this MR do and why?
Clean up MergeTrains::Train
specs
Consolidate the logic testing to #all_cars
, which is doing most of
the work in this class. Also cleared up some factory overuse.
This change is probably best reviewed as whole files, before and after. There's lots of indentation changes and rearrangement that make the diff sort of a mess.
The upshot is:
- We still test all the methods
- I removed the business logic tests from
#first_car
and#car_count
, because they're both simply relation methods executed on#all_cars
, which we do test for underlying business logic here.
% git checkout master
Switched to branch 'master'
% FPROF=1 bundle exec rspec ee/spec/models/merge_trains/train_spec.rb
Test environment set up in 5.32647 seconds
..................
Finished in 18.57 seconds (files took 10.7 seconds to load)
18 examples, 0 failures
[TEST PROF INFO] Time spent in factories: 00:11.614 (58.85% of total time)
Total: 31
Total top-level: 24
Total time: 00:11.614 (out of 00:25.685)
Total uniq factories: 4
total top-level total time time per call top-level time name
22 22 9.5887s 0.4359s 9.5887s merge_request
4 1 6.3494s 1.5874s 2.0167s project
4 0 0.5446s 0.1362s 0.0000s namespace
1 1 0.0095s 0.0095s 0.0095s license
% git checkout 298541-train-object-followups
Switched to branch '298541-train-object-followups'
% FPROF=1 bundle exec rspec ee/spec/models/merge_trains/train_spec.rb
Test environment set up in 5.80484 seconds
............
Finished in 11.08 seconds (files took 14.02 seconds to load)
12 examples, 0 failures
[TEST PROF INFO] Time spent in factories: 00:03.678 (29.43% of total time)
Total: 11
Total top-level: 10
Total time: 00:03.678 (out of 00:19.154)
Total uniq factories: 4
total top-level total time time per call top-level time name
8 8 1.8011s 0.2251s 1.8011s merge_request
1 1 0.0097s 0.0097s 0.0097s license
1 1 1.8673s 1.8673s 1.8673s project
1 0 0.2740s 0.2740s 0.0000s namespace
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #298541 (closed)
Edited by drew stachon