2017-04-17 10:58:03 -07:00
|
|
|
require 'rails_helper'
|
2017-04-12 07:03:37 -07:00
|
|
|
|
2017-04-17 10:58:03 -07:00
|
|
|
describe 'The webfinger route' do
|
2017-04-12 07:03:37 -07:00
|
|
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
|
|
|
|
2017-04-17 10:58:03 -07:00
|
|
|
describe 'requested with standard accepts headers' do
|
|
|
|
it 'returns a json response' do
|
|
|
|
get webfinger_url(resource: alice.to_webfinger_s)
|
2017-04-12 07:03:37 -07:00
|
|
|
|
2018-04-21 12:35:07 -07:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-17 10:58:03 -07:00
|
|
|
expect(response.content_type).to eq 'application/jrd+json'
|
2017-04-12 07:03:37 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-17 10:58:03 -07:00
|
|
|
describe 'asking for xml format' do
|
|
|
|
it 'returns an xml response for xml format' do
|
|
|
|
get webfinger_url(resource: alice.to_webfinger_s, format: :xml)
|
|
|
|
|
2018-04-21 12:35:07 -07:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-17 10:58:03 -07:00
|
|
|
expect(response.content_type).to eq 'application/xrd+xml'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns an xml response for xml accept header' do
|
|
|
|
headers = { 'HTTP_ACCEPT' => 'application/xrd+xml' }
|
|
|
|
get webfinger_url(resource: alice.to_webfinger_s), headers: headers
|
2017-04-12 07:03:37 -07:00
|
|
|
|
2018-04-21 12:35:07 -07:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-17 10:58:03 -07:00
|
|
|
expect(response.content_type).to eq 'application/xrd+xml'
|
2017-04-12 07:03:37 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-17 10:58:03 -07:00
|
|
|
describe 'asking for json format' do
|
|
|
|
it 'returns a json response for json format' do
|
|
|
|
get webfinger_url(resource: alice.to_webfinger_s, format: :json)
|
|
|
|
|
2018-04-21 12:35:07 -07:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-17 10:58:03 -07:00
|
|
|
expect(response.content_type).to eq 'application/jrd+json'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a json response for json accept header' do
|
|
|
|
headers = { 'HTTP_ACCEPT' => 'application/jrd+json' }
|
|
|
|
get webfinger_url(resource: alice.to_webfinger_s), headers: headers
|
2017-04-12 07:03:37 -07:00
|
|
|
|
2018-04-21 12:35:07 -07:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-17 10:58:03 -07:00
|
|
|
expect(response.content_type).to eq 'application/jrd+json'
|
2017-04-12 07:03:37 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|