enriclluelles/route_translator — pull request #65 by omnikron (2014-07-17 10:35:35+00:00)
Title: Host locales path helpers fix

OK. Sorry for submitting multiple pull requests in a row and closing them, my branch's build was failing in Travis, I thought it was because of my changes and I got very confused. Also I didn't realise I could run Travis builds on my own fork directly, so I submitted the PR to trigger the build. Very stupid, sorry.

It turns out my branch was failing because the [master branch is currently failing](https://travis-ci.org/omnikron/route_translator/builds/30149925) for rails 3.1, 3.2 and 4.0. This is because an [update](https://github.com/svenfuchs/i18n/releases/tag/v0.6.11) to I18n means that stubbing `available_locales` in [this line](https://github.com/enriclluelles/route_translator/blob/master/test/routing_test.rb#L333) was no longer working.

So this PR now fixes that failing test as well as the original pull request which is as follows:

> Unfortunately I introduced a bug in my last PR (the bug only occurs when using the host_locales option). The path helpers were incorrectly returning nil when given anything other than a hash as an argument. This PR fixes the bug and adds a test for it.

>While I was there I did some refactoring of the add_untranslated_helpers_to_controllers_and_views method to make it a bit more readable, as there was some unnecessary repetition of `__send__` etc. If you don't like this change then I can also resubmit this PR with just the fix above.

>I also moved locale_param_key back to lib/route_translator.rb, I had moved this to lib/route_translator/host.rb but I think it makes more sense in its original position.