Since top-level constant lookup has been removed on Ruby 2.5, Rails takes care of relevant changes on its side, so that we rely on properly scoped constants, instead of relying on fallback lookup.
If a process is forked more than once, the Active Record connection pool was grabbing the oldest connection specification for a process, and not the most recent one.
This issue is not seen for single processes, but if you are forking the process multiple times, the wrong specification will be returned and incorrect connection will be used.
This change fixes the issue by reversing the list of specification names so we can grab the most recent one rather than the oldest.
Previously when using time travel methods, travel_to, etc, and calling now on a subclass of e.g. Time, it would return an instance of Time instead of returning an instance of the subclass.
This change fixes the way we return the instance, so that we always return using the correct class.