2023-02-22 11:55:31 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-07 01:31:03 +11:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 13:49:53 +10:00
|
|
|
RSpec.describe InstanceActorsController do
|
2022-02-07 01:31:03 +11:00
|
|
|
describe 'GET #show' do
|
2023-05-04 13:49:08 +10:00
|
|
|
context 'with JSON' do
|
2022-02-07 01:31:03 +11:00
|
|
|
let(:format) { 'json' }
|
|
|
|
|
|
|
|
shared_examples 'shared behavior' do
|
|
|
|
before do
|
|
|
|
get :show, params: { format: format }
|
|
|
|
end
|
|
|
|
|
2024-02-27 22:50:21 +11:00
|
|
|
it 'returns http success with correct media type and body' do
|
2024-02-17 00:00:11 +11:00
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
.and have_attributes(
|
2024-02-27 22:50:21 +11:00
|
|
|
media_type: eq('application/activity+json')
|
2024-02-17 00:00:11 +11:00
|
|
|
)
|
2022-02-07 01:31:03 +11:00
|
|
|
|
2024-01-27 03:28:50 +11:00
|
|
|
expect(body_as_json)
|
|
|
|
.to include(:id, :type, :preferredUsername, :inbox, :publicKey, :inbox, :outbox, :url)
|
2022-02-07 01:31:03 +11:00
|
|
|
end
|
2024-02-27 22:50:21 +11:00
|
|
|
|
|
|
|
it_behaves_like 'cacheable response'
|
2022-02-07 01:31:03 +11:00
|
|
|
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 09:10:19 +11:00
|
|
|
|
2022-02-07 01:31:03 +11:00
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with authorized fetch mode' do
|
|
|
|
let(:authorized_fetch_mode) { true }
|
2023-02-19 09:10:19 +11:00
|
|
|
|
2022-02-07 01:31:03 +11:00
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
2024-03-14 02:43:40 +11:00
|
|
|
|
|
|
|
context 'with a suspended instance actor' do
|
|
|
|
let(:authorized_fetch_mode) { false }
|
|
|
|
|
|
|
|
before { Account.representative.update(suspended_at: 10.days.ago) }
|
|
|
|
|
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
2022-02-07 01:31:03 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|