rails/rails — pull request #16756 by huoxito (2014-08-30 22:51:26+00:00)
Title: Dont mess with default order engines load (4.1.6.rc1 regression)

When copying migrations some engines might depend on schema from other
engine so we can't blindly reverse all railties collection as that would
affect the order they were originally loaded. This patch helps to only
apply the order from engines specified in `railties_order`

related https://github.com/rails/rails/issues/16614 and https://github.com/rails/rails/pull/15269

I tried to fix this without changing what gets returned by `ordered_railties` but it's was getting too complicated and `ordered_railties` is private api only used by `railties_initializers`, afaik, so I think it's fine? Returning the original specified railties + all other railties in a single array key makes it easier to reverse only where we really need to. Please let me know if that doesn't make any sense.

Motivation here was to fix the spree builds, there we have an api engine with migrations that depend on the core engine so it's important that rails copies the core migrations first.

apologize for the lack of specs here, was trying to reproduce it via a test but failed miserably, will give another try later today or tomorrow.