diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index bf19c53..d35e543 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -94,8 +94,10 @@ class AccountController < ApplicationController # action to perform logout from the application def logout - self.current_user.person.update_attribute(:last_lang, cookies[:lang]) - self.current_user.forget_me if logged_in? + if logged_in? + self.current_user.person.update_attribute(:last_lang, cookies[:lang]) + self.current_user.forget_me + end cookies.delete :auth_token reset_session flash[:notice] = _("You have been logged out.") diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index a96773c..89d7a95 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -627,6 +627,14 @@ class AccountControllerTest < Test::Unit::TestCase assert_tag :tag => 'input', :attributes => { :name => "profile_data[contact_phone]" } end + should 'redirect to login when unlogged user try logout' do + logout + assert_nothing_raised NoMethodError do + get :logout + assert_redirected_to :action => 'index' + end + end + protected def new_user(options = {}, extra_options ={}) data = {:profile_data => person_data} -- libgit2 0.21.2