diff --git a/Changelog.md b/Changelog.md index a6998d4b7..f2aaee042 100644 --- a/Changelog.md +++ b/Changelog.md @@ -127,7 +127,8 @@ Contributions are very welcome, the hard work is done! ## Refactor ## Bug fixes -* Fix empty name field when editing aspect names [#6548](https://github.com/diaspora/diaspora/issues/6548) +* Fix empty name field when editing aspect names [#6706](https://github.com/diaspora/diaspora/pull/6706) +* Fix internal server error when trying to log out of an expired session [#6707](https://github.com/diaspora/diaspora/pull/6707) ## Features diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 05016d2a7..61f464209 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,6 +7,6 @@ class SessionsController < Devise::SessionsController before_filter :reset_authentication_token, :only => [:destroy] def reset_authentication_token - current_user.reset_authentication_token! + current_user.reset_authentication_token! unless current_user.nil? end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 5b802635c..4ba846ed1 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -47,4 +47,26 @@ describe SessionsController, type: :controller do expect(response).to redirect_to root_path end end + + describe "#reset_authentication_token" do + context "for a logged in user" do + before do + sign_in :user, @user + end + + it "succeeds" do + expect { @controller.send(:reset_authentication_token) }.to_not raise_error + end + end + + context "for a logged out user" do + before do + sign_out :user + end + + it "succeeds" do + expect { @controller.send(:reset_authentication_token) }.to_not raise_error + end + end + end end