Reduce the responsibilities of ComponentVersions
Addresses technical debt outlined in #389 (closed) for the
ComponentVersions class, such that the class will better adhere to the Single Responsibility Principle, and its functionality will better match its name, i.e., it gets the component versions in gitlab-rails, with methods for returning them in formats that Omnibus and CNG work with.
Builder::CNGImage, the refactoring roughly followed this process:
Move the methods exactly as-is from
ComponentVersions, along with specs
Make the methods instance methods rather than class methods
Remove the type-specific naming (e.g.,
Remove the branch argument, relying on the internal instance variable provided to the class's initializer
version_mapargument, relying on the internal
attr_readerand the value assigned during
update_*method as it was basically a wrapper for this very simple logic that was moved directly into the
if changes? commit else # log end
All of this greatly reduced the number of necessary specs, due to making the "helper" methods internal private methods. Because all we need to end up testing is:
- Does the class fetch the versions from
ComponentVersionsformatted for its respective builder?
- When those versions are identical to what's defined in the builder, do we do nothing?
- When those versions differ from what's defined in the builder, do we commit the changes?
So while this MR shows a bunch of deleted tests, we're still covering the same amount of functionality.