Commit 7708caad9f62f260b567912dc0666e42dbe335cf
Committed by
Antonio Terceiro
1 parent
e1db8da3
Exists in
master
and in
29 other branches
ActionItem1121: don't crash when logged out user tries to log out
Showing
2 changed files
with
12 additions
and
2 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -94,8 +94,10 @@ class AccountController < ApplicationController |
94 | 94 | |
95 | 95 | # action to perform logout from the application |
96 | 96 | def logout |
97 | - self.current_user.person.update_attribute(:last_lang, cookies[:lang]) | |
98 | - self.current_user.forget_me if logged_in? | |
97 | + if logged_in? | |
98 | + self.current_user.person.update_attribute(:last_lang, cookies[:lang]) | |
99 | + self.current_user.forget_me | |
100 | + end | |
99 | 101 | cookies.delete :auth_token |
100 | 102 | reset_session |
101 | 103 | flash[:notice] = _("You have been logged out.") | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -627,6 +627,14 @@ class AccountControllerTest < Test::Unit::TestCase |
627 | 627 | assert_tag :tag => 'input', :attributes => { :name => "profile_data[contact_phone]" } |
628 | 628 | end |
629 | 629 | |
630 | + should 'redirect to login when unlogged user try logout' do | |
631 | + logout | |
632 | + assert_nothing_raised NoMethodError do | |
633 | + get :logout | |
634 | + assert_redirected_to :action => 'index' | |
635 | + end | |
636 | + end | |
637 | + | |
630 | 638 | protected |
631 | 639 | def new_user(options = {}, extra_options ={}) |
632 | 640 | data = {:profile_data => person_data} | ... | ... |