log_out_spec.rb 724 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Log Out' do
  4. include RoutingHelper
  5. describe 'DELETE /auth/sign_out' do
  6. let(:user) { Fabricate(:user) }
  7. before do
  8. sign_in user
  9. end
  10. it 'Logs out the user and redirect' do
  11. delete '/auth/sign_out'
  12. expect(response).to redirect_to('/auth/sign_in')
  13. end
  14. it 'Logs out the user and return a page to redirect to with a JSON request' do
  15. delete '/auth/sign_out', headers: { 'HTTP_ACCEPT' => 'application/json' }
  16. expect(response).to have_http_status(200)
  17. expect(response.media_type).to eq 'application/json'
  18. expect(response.parsed_body[:redirect_to]).to eq '/auth/sign_in'
  19. end
  20. end
  21. end