Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sessions controller): call reset_session on destroy #251

Merged
merged 1 commit into from
Jun 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/devise_token_auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module DeviseTokenAuth
class SessionsController < DeviseTokenAuth::ApplicationController
before_filter :set_user_by_token, :only => [:destroy]
after_action :reset_session, :only => [:destroy]

def create
# Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class DeviseTokenAuth::SessionsControllerTest < ActionController::TestCase

describe 'authed user sign out' do
before do
def @controller.reset_session_called; @reset_session_called == true; end
def @controller.reset_session; @reset_session_called = true; end
@auth_headers = @existing_user.create_new_auth_token
request.headers.merge!(@auth_headers)
xhr :delete, :destroy, format: :json
Expand All @@ -103,6 +105,10 @@ class DeviseTokenAuth::SessionsControllerTest < ActionController::TestCase
@existing_user.reload
refute @existing_user.tokens[@auth_headers["client"]]
end

test "session was destroyed" do
assert_equal true, @controller.reset_session_called
end
end

describe 'unauthed user sign out' do
Expand Down