diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 3eb6021..b20249b 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -154,7 +154,7 @@ class AccountController < ApplicationController # action to perform logout from the application def logout - if logged_in? + if logged_in? && self.current_user.id.present? self.current_user.forget_me end reset_session diff --git a/plugins/oauth_client/test/functional/account_controller_test.rb b/plugins/oauth_client/test/functional/account_controller_test.rb new file mode 100644 index 0000000..0ff02f4 --- /dev/null +++ b/plugins/oauth_client/test/functional/account_controller_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class AccountControllerTest < ActionController::TestCase + def setup + external_person = ExternalPerson.create!(identifier: 'johnlock', + name: 'John Locke', + source: 'anerenvironment.org', + email: 'john@locke.org', + created_at: Date.yesterday + ) + session[:external] = external_person.id + end + + should "not create an User when logging out" do + assert_no_difference 'User.count' do + get :logout + end + end +end -- libgit2 0.21.2