Sha256: 17f953e4993a44e0f276ed4ddb81d43240189fc844fe4514ccd2fb1bfcb5b52b

Contents?: true

Size: 995 Bytes

Versions: 6

Compression:

Stored size: 995 Bytes

Contents

RSpec.describe Commons::Authentication::AuthenticateByJWT, type: :request do
  describe 'when calling /misc/application_parameters' do
    context 'raises error as an unauthenticated user' do
      subject do
        get "/misc/application_parameters",
            params: {}.to_json,
            headers: {
              'content-type': 'application/json'
            }
        response
      end

      it do
        is_expected.to have_http_status(:unauthorized)
      end
    end

    context 'works ok as an authenticated user' do
      let(:user) { create(:user) }
      let(:jwt) { Commons::Authentication::JSONWebToken.encode(user_id: user.id) }

      subject do
        get "/misc/application_parameters",
            params: {}.to_json,
            headers: {
              'content-type': 'application/json',
              'Authorization': 'Bearer ' + jwt
            }
        response
      end

      it do
        is_expected.to have_http_status(:ok)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commons_yellowme-0.16.0 spec/commons/authentication/authenticate_by_jwt_spec.rb
commons_yellowme-0.15.0 spec/commons/authentication/authenticate_by_jwt_spec.rb
commons_yellowme-0.12.0 spec/commons/authentication/authenticate_by_jwt_spec.rb
commons_yellowme-0.11.3 spec/commons/authentication/authenticate_by_jwt_spec.rb
commons_yellowme-0.11.2 spec/commons/authentication/authenticate_by_jwt_spec.rb
commons_yellowme-0.11.1 spec/commons/authentication/authenticate_by_jwt_spec.rb