summaryrefslogtreecommitdiff
path: root/spec/requests/sessions_controller/destroy_sessions_controller_spec.rb
blob: bc669fc0ab75b834fbf76e9ff10d1534313d2346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'DELETE /api/logout', type: :request do
  let(:user) { create(:user_account) }
  let(:token) { jwt(user) }

  it "returns status 204 and deletes the user's session key" do
    delete('/api/logout', headers: { 'Authorization' => "Bearer #{token['token']}" })
    expect(response).to have_http_status(204)
    user.reload
    expect(user.session_key).to be_nil
  end
end