2023-02-22 02:55:31 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-06 16:31:03 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 06:49:53 +03:00
|
|
|
RSpec.describe InstanceActorsController do
|
2022-02-06 16:31:03 +02:00
|
|
|
describe 'GET #show' do
|
2023-05-04 06:49:08 +03:00
|
|
|
context 'with JSON' do
|
2022-02-06 16:31:03 +02:00
|
|
|
let(:format) { 'json' }
|
|
|
|
|
|
|
|
shared_examples 'shared behavior' do
|
|
|
|
before do
|
|
|
|
get :show, params: { format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns application/activity+json' do
|
|
|
|
expect(response.media_type).to eq 'application/activity+json'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not set cookies' do
|
|
|
|
expect(response.cookies).to be_empty
|
2023-02-17 14:45:27 +02:00
|
|
|
expect(response.headers['Set-Cookies']).to be_nil
|
2022-02-06 16:31:03 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not set sessions' do
|
|
|
|
expect(session).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns public Cache-Control header' do
|
|
|
|
expect(response.headers['Cache-Control']).to include 'public'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders account' do
|
|
|
|
json = body_as_json
|
|
|
|
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :inbox, :outbox, :url)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:authorized_fetch_mode?).and_return(authorized_fetch_mode)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without authorized fetch mode' do
|
|
|
|
let(:authorized_fetch_mode) { false }
|
2023-02-19 00:10:19 +02:00
|
|
|
|
2022-02-06 16:31:03 +02:00
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with authorized fetch mode' do
|
|
|
|
let(:authorized_fetch_mode) { true }
|
2023-02-19 00:10:19 +02:00
|
|
|
|
2022-02-06 16:31:03 +02:00
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|