diff --git a/Changelog.md b/Changelog.md index 7f75719fb..f14718b1e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -69,6 +69,7 @@ The keys will still be available in the root level within the 0.5 release. The o * Fix poll creation on Bootstrap pages [#5334](https://github.com/diaspora/diaspora/pull/5334) * Show error message on invalid reset password attempt [#5325](https://github.com/diaspora/diaspora/pull/5325) * Fix translations on mobile password reset pages [#5318](https://github.com/diaspora/diaspora/pull/5318) +* Handle unset user agent when signing out [#5316](https://github.com/diaspora/diaspora/pull/5316) ## Features * Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105) 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