instance_actors_controller_spec.rb 1.5 KB

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