2024-08-13 17:49:23 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 05:12:25 +00:00
|
|
|
RSpec.describe 'Log Out' do
|
2024-08-13 17:49:23 +00:00
|
|
|
include RoutingHelper
|
|
|
|
|
|
|
|
describe 'DELETE /auth/sign_out' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Logs out the user and redirect' do
|
|
|
|
delete '/auth/sign_out'
|
|
|
|
|
|
|
|
expect(response).to redirect_to('/auth/sign_in')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Logs out the user and return a page to redirect to with a JSON request' do
|
|
|
|
delete '/auth/sign_out', headers: { 'HTTP_ACCEPT' => 'application/json' }
|
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response.media_type).to eq 'application/json'
|
|
|
|
|
2024-09-06 09:58:46 +00:00
|
|
|
expect(response.parsed_body[:redirect_to]).to eq '/auth/sign_in'
|
2024-08-13 17:49:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|