forked from mastodon/mastodon
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to request specs in
/api/v1/apps/verify_credentials
(mastod…
- Loading branch information
1 parent
be2e3dc
commit 0d31ddc
Showing
2 changed files
with
44 additions
and
45 deletions.
There are no files selected for viewing
45 changes: 0 additions & 45 deletions
45
spec/controllers/api/v1/apps/credentials_controller_spec.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |