Sha256: 72b44383f38e99054e75f2611010f58cd8aa8f19aef7db288a817f56657dcc3e
Contents?: true
Size: 1.7 KB
Versions: 6
Compression:
Stored size: 1.7 KB
Contents
require 'rails_helper' RSpec.describe 'Logout Requests' do include_context 'with graphql query request' let(:user) { create(:user, :confirmed) } let(:query) do <<-GRAPHQL mutation { userLogout { authenticable { email } } } GRAPHQL end before { post_request } context 'when user is logged in' do let(:headers) { user.create_new_auth_token } it 'logs out the user' do expect(response).not_to include_auth_headers expect(user.reload.tokens.keys).to be_empty expect(json_response[:data][:userLogout]).to match( authenticable: { email: user.email } ) expect(json_response[:errors]).to be_nil end end context 'when user is not logged in' do it 'returns an error' do expect(response).not_to include_auth_headers expect(user.reload.tokens.keys).to be_empty expect(json_response[:data][:userLogout]).to be_nil expect(json_response[:errors]).to contain_exactly( hash_including(message: 'User was not found or was not logged in.', extensions: { code: 'USER_ERROR' }) ) end end context 'when using the admin model' do let(:query) do <<-GRAPHQL mutation { adminLogout { authenticable { email } } } GRAPHQL end let(:admin) { create(:admin, :confirmed) } let(:headers) { admin.create_new_auth_token } it 'logs out the admin' do expect(response).not_to include_auth_headers expect(admin.reload.tokens.keys).to be_empty expect(json_response[:data][:adminLogout]).to match( authenticable: { email: admin.email } ) expect(json_response[:errors]).to be_nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems