The problem seems to be with all tests that do POST, PUT, DELETE requests. It seems that csrf token is not being attached with those requests. Thus I get redirected to /login. It's perfectly fine with GET requests of course.
It's worth to mention that actual browser interactions are fine. So it works in dev, but not in test environment.
Anybody else seen this?
Ok, So the issue was with protect_from_forgery
. For some unknown to me reason before_filter :login_required
was triggering too early. I don't know the specifics or how to 'properly' fix this. But doing this allows me to run my test finally:
protect_from_forgery unless Rails.env.test?