diff options
author | James Kiesel <james.kiesel@gmail.com> | 2014-10-09 14:08:33 +0400 |
---|---|---|
committer | James Kiesel <james.kiesel@gmail.com> | 2014-10-09 14:08:33 +0400 |
commit | 2d44107b5d54e99d57360fee024b99c873211e65 (patch) | |
tree | 848e923c4b2cd0b9ff28231801fbebb37140f978 | |
parent | d44300c7a2b7bc8bd33ab880134695d0dc75d490 (diff) |
Allow nil HTTP user agent
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f95636f60..327b6068c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 1b2e44ff3..3910e9461 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -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 |