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.

55 lines
1.5 KiB

  1. require 'rails_helper'
  2. RSpec.describe InstanceActorsController, type: :controller do
  3. describe 'GET #show' do
  4. context 'as JSON' do
  5. let(:format) { 'json' }
  6. shared_examples 'shared behavior' do
  7. before do
  8. get :show, params: { format: format }
  9. end
  10. it 'returns http success' do
  11. expect(response).to have_http_status(200)
  12. end
  13. it 'returns application/activity+json' do
  14. expect(response.media_type).to eq 'application/activity+json'
  15. end
  16. it 'does not set cookies' do
  17. expect(response.cookies).to be_empty
  18. expect(response.headers['Set-Cookies']).to be nil
  19. end
  20. it 'does not set sessions' do
  21. expect(session).to be_empty
  22. end
  23. it 'returns public Cache-Control header' do
  24. expect(response.headers['Cache-Control']).to include 'public'
  25. end
  26. it 'renders account' do
  27. json = body_as_json
  28. expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :inbox, :outbox, :url)
  29. end
  30. end
  31. before do
  32. allow(controller).to receive(:authorized_fetch_mode?).and_return(authorized_fetch_mode)
  33. end
  34. context 'without authorized fetch mode' do
  35. let(:authorized_fetch_mode) { false }
  36. it_behaves_like 'shared behavior'
  37. end
  38. context 'with authorized fetch mode' do
  39. let(:authorized_fetch_mode) { true }
  40. it_behaves_like 'shared behavior'
  41. end
  42. end
  43. end
  44. end