Allow nil HTTP user agent

This commit is contained in:
James Kiesel 2014-10-09 23:08:33 +13:00
parent d44300c7a2
commit 2d44107b5d
2 changed files with 8 additions and 1 deletions

View file

@ -36,7 +36,7 @@ class ApplicationController < ActionController::Base
def after_sign_out_path_for(resource_or_scope)
# mobile_fu's is_mobile_device? wasn't working here for some reason...
# it may have been just because of the test env.
if request.env['HTTP_USER_AGENT'].match(/mobile/i)
if request.env['HTTP_USER_AGENT'].try(:match, /mobile/i)
root_path
else
new_user_session_path

View file

@ -91,4 +91,11 @@ describe ApplicationController, :type => :controller do
end
end
end
describe "#after_sign_out_path_for" do
it "can handle a nil HTTP_USER_AGENT" do
@request.headers["HTTP_USER_AGENT"] = nil
expect(@controller.send(:after_sign_out_path_for, alice)).to eq(new_user_session_path)
end
end
end