instance_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Instances' do
  4. let(:user) { Fabricate(:user) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
  6. let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
  7. describe 'GET /api/v1/instance' do
  8. context 'when not logged in' do
  9. it 'returns http success and json' do
  10. get api_v1_instance_path
  11. expect(response)
  12. .to have_http_status(200)
  13. expect(response.content_type)
  14. .to start_with('application/json')
  15. expect(response.parsed_body)
  16. .to be_present
  17. .and include(title: 'Mastodon')
  18. end
  19. end
  20. context 'when logged in' do
  21. it 'returns http success and json' do
  22. get api_v1_instance_path, headers: headers
  23. expect(response)
  24. .to have_http_status(200)
  25. expect(response.content_type)
  26. .to start_with('application/json')
  27. expect(response.parsed_body)
  28. .to be_present
  29. .and include(title: 'Mastodon')
  30. end
  31. end
  32. end
  33. end