Sha256: 8aaf8c3716d96a08f2717a05390674d4162873f7a96343f3017cdc6607fcb0a9
Contents?: true
Size: 1.15 KB
Versions: 11
Compression:
Stored size: 1.15 KB
Contents
require 'rails_helper' module ApiUserAuth RSpec.describe TestController, type: :controller do context 'Test functional' do before(:example) do AuthUser.create_by_params( email: 'user@mail.com', password: '123456' ) end let(:auth_user) { AuthUser.last } it 'Valid' do expect(AuthUser.count).to eq(1) request.headers.merge!({ 'HTTP_AUTHORIZATION' => "Bearer #{auth_user.auth_tokens.last}" }) get :index expect(response).to have_http_status(200) end it 'Invalid' do expect(AuthUser.count).to eq(1) get :index expect(response).to have_http_status(401) expect(resp_json[:message]).to_not be_blank request.headers.merge!({ 'HTTP_AUTHORIZATION' => 'Bearer token_goes_here' }) get :index expect(response).to have_http_status(401) expect(resp_json[:message]).to_not be_blank request.headers.merge!({ 'HTTP_AUTHORIZATION' => "Bearer #{SecureRandom.uuid}" }) get :index expect(response).to have_http_status(401) expect(resp_json[:message]).to_not be_blank end end end end
Version data entries
11 entries across 11 versions & 1 rubygems