How can I set the locale of the request inside a (spock) unit test method?
I've tried do
request.addHeader('Accept-Language', 'sv-SE')
and adding
environments {
test {
Locale.setDefault(new Locale('sv_SE'))
}
in BootStrap.groovy, but request.locale still gives 'en'.
I've also tried to use the localeResolver (def localeResolver, applicationContext.localeResolver and applicationContext.getBean('localeResolver')) but all I get is null.
request.locale and request.locales are both read-only btw.
Running Grails-2.0.3 and spock-0.6.
Google didn't help me, so any suggestions are welcome!
/David