Fixes test for Gemfile entry changes

Broken by fbe38c9e9d4fe9f82518e8ffc1d757459b0c5f1c
Merge pull request #16429 from arunagw/aa-build-fix-gemfile-spring

Fixes test for Gemfile entry changes
add a test for prepending SCRIPT_NAME to generated urls
save a hash allocation per request.
fix nested `has many :through` associations on unpersisted instances