I am trying to avoid using my session[:referred_by], and would like to use the request.referrer. However, my RSpec tests fail because the TestRequest does not store a request.referrer
So I have to do the following in order for Rspec tests to work. Is there a way to make it better:
referrer = request.referrer ? request.referrer : '/'
redirect_to referrer, :alert => error_message
Mock it:
Or if you don’t care if it doesn’t get called, stub it: