nodeinfo_controller_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. describe WellKnown::NodeInfoController, type: :controller do
  3. render_views
  4. describe 'GET #index' do
  5. it 'returns json document pointing to node info' do
  6. get :index
  7. expect(response).to have_http_status(200)
  8. expect(response.media_type).to eq 'application/json'
  9. json = body_as_json
  10. expect(json[:links]).to be_an Array
  11. expect(json[:links][0][:rel]).to eq 'http://nodeinfo.diaspora.software/ns/schema/2.0'
  12. expect(json[:links][0][:href]).to include 'nodeinfo/2.0'
  13. end
  14. end
  15. describe 'GET #show' do
  16. it 'returns json document with node info properties' do
  17. get :show
  18. expect(response).to have_http_status(200)
  19. expect(response.media_type).to eq 'application/json'
  20. json = body_as_json
  21. expect({ "foo" => 0 }).not_to match_json_schema("nodeinfo_2.0")
  22. expect(json).to match_json_schema("nodeinfo_2.0")
  23. expect(json[:version]).to eq '2.0'
  24. expect(json[:usage]).to be_a Hash
  25. expect(json[:software]).to be_a Hash
  26. expect(json[:protocols]).to be_an Array
  27. end
  28. end
  29. end