Skip to content

Commit

Permalink
Migrate to request specs in /api/v1/apps/verify_credentials (mastod…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmbrasil authored and skerit committed Jul 7, 2023
1 parent be2e3dc commit 0d31ddc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
45 changes: 0 additions & 45 deletions spec/controllers/api/v1/apps/credentials_controller_spec.rb

This file was deleted.

44 changes: 44 additions & 0 deletions spec/requests/api/v1/apps/credentials_spec.rb
@@ -0,0 +1,44 @@
# frozen_string_literal: true

require 'rails_helper'

describe 'Credentials' do
describe 'GET /api/v1/apps/verify_credentials' do
subject do
get '/api/v1/apps/verify_credentials', headers: headers
end

context 'with an oauth token' do
let(:token) { Fabricate(:accessible_access_token, scopes: 'read', application: Fabricate(:application)) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }

it 'returns http success' do
subject

expect(response).to have_http_status(200)
end

it 'returns the app information correctly' do
subject

expect(body_as_json).to match(
a_hash_including(
name: token.application.name,
website: token.application.website,
vapid_key: Rails.configuration.x.vapid_public_key
)
)
end
end

context 'without an oauth token' do
let(:headers) { {} }

it 'returns http unauthorized' do
subject

expect(response).to have_http_status(401)
end
end
end
end

0 comments on commit 0d31ddc

Please sign in to comment.