alphagov/whitehall — pull request #1496 by GrouchPotato (2014-05-22 12:06:33+00:00)
Title: PubDocRoutesHelper is always explicit about locale

Fixes: https://www.pivotaltracker.com/story/show/71661194

:polymorphic_url, used by :document_url in PublicDocumentRoutesHelper,
uses the current locale when generating routes if a locale is not
explicitly given. This meant that when in a foreign locale it would
generate a url in that locale when given an english edition, even if
that edition wasn't translated into the locale.

This commit changes the behaviour to always be explicit about locale
with the following logic:

• If a :locale option is given, use that.

• Otherwise if we're in a foreign locale and the given edition is
available in that locale, use that locale.

• Otherwise, use english.