闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. require 'rails_helper'
  2. describe 'The webfinger route' do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. describe 'requested with standard accepts headers' do
  5. it 'returns a json response' do
  6. get webfinger_url(resource: alice.to_webfinger_s)
  7. expect(response).to have_http_status(:success)
  8. expect(response.content_type).to eq 'application/jrd+json'
  9. end
  10. end
  11. describe 'asking for xml format' do
  12. it 'returns an xml response for xml format' do
  13. get webfinger_url(resource: alice.to_webfinger_s, format: :xml)
  14. expect(response).to have_http_status(:success)
  15. expect(response.content_type).to eq 'application/xrd+xml'
  16. end
  17. it 'returns an xml response for xml accept header' do
  18. headers = { 'HTTP_ACCEPT' => 'application/xrd+xml' }
  19. get webfinger_url(resource: alice.to_webfinger_s), headers: headers
  20. expect(response).to have_http_status(:success)
  21. expect(response.content_type).to eq 'application/xrd+xml'
  22. end
  23. end
  24. describe 'asking for json format' do
  25. it 'returns a json response for json format' do
  26. get webfinger_url(resource: alice.to_webfinger_s, format: :json)
  27. expect(response).to have_http_status(:success)
  28. expect(response.content_type).to eq 'application/jrd+json'
  29. end
  30. it 'returns a json response for json accept header' do
  31. headers = { 'HTTP_ACCEPT' => 'application/jrd+json' }
  32. get webfinger_url(resource: alice.to_webfinger_s), headers: headers
  33. expect(response).to have_http_status(:success)
  34. expect(response.content_type).to eq 'application/jrd+json'
  35. end
  36. end
  37. end