Commit ef5d596c93cdcf212db043b0404ae7bd0141971f

Authored by Gabriel Silva
1 parent 64134001

Fixes logout bug

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Dylan Guedes <djmgguedes@gmail.com>
app/controllers/public/account_controller.rb
@@ -154,7 +154,7 @@ class AccountController &lt; ApplicationController @@ -154,7 +154,7 @@ class AccountController &lt; ApplicationController
154 154
155 # action to perform logout from the application 155 # action to perform logout from the application
156 def logout 156 def logout
157 - if logged_in? 157 + if logged_in? && self.current_user.id.present?
158 self.current_user.forget_me 158 self.current_user.forget_me
159 end 159 end
160 reset_session 160 reset_session
plugins/oauth_client/test/functional/account_controller_test.rb 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +require 'test_helper'
  2 +
  3 +class AccountControllerTest < ActionController::TestCase
  4 + def setup
  5 + external_person = ExternalPerson.create!(identifier: 'johnlock',
  6 + name: 'John Locke',
  7 + source: 'anerenvironment.org',
  8 + email: 'john@locke.org',
  9 + created_at: Date.yesterday
  10 + )
  11 + session[:external] = external_person.id
  12 + end
  13 +
  14 + should "not create an User when logging out" do
  15 + assert_no_difference 'User.count' do
  16 + get :logout
  17 + end
  18 + end
  19 +end