2023-02-22 09:55:31 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-06 23:31:03 +09:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 12:49:53 +09:00
|
|
|
RSpec.describe InstanceActorsController do
|
2022-02-06 23:31:03 +09:00
|
|
|
describe 'GET #show' do
|
2023-05-04 12:49:08 +09:00
|
|
|
context 'with JSON' do
|
2022-02-06 23:31:03 +09:00
|
|
|
let(:format) { 'json' }
|
|
|
|
|
|
|
|
shared_examples 'shared behavior' do
|
|
|
|
before do
|
|
|
|
get :show, params: { format: format }
|
|
|
|
end
|
|
|
|
|
2024-01-27 01:28:50 +09:00
|
|
|
it 'returns http success with correct media type, headers, and session values' do
|
2024-02-16 22:00:11 +09:00
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
.and have_attributes(
|
|
|
|
media_type: eq('application/activity+json'),
|
|
|
|
cookies: be_empty
|
|
|
|
)
|
2022-02-06 23:31:03 +09:00
|
|
|
|
2024-02-16 22:00:11 +09:00
|
|
|
expect(response.headers)
|
|
|
|
.to include('Cache-Control' => include('public'))
|
|
|
|
.and not_include('Set-Cookies')
|
2022-02-06 23:31:03 +09:00
|
|
|
|
|
|
|
expect(session).to be_empty
|
|
|
|
|
2024-01-27 01:28:50 +09:00
|
|
|
expect(body_as_json)
|
|
|
|
.to include(:id, :type, :preferredUsername, :inbox, :publicKey, :inbox, :outbox, :url)
|
2022-02-06 23:31:03 +09:00
|
|
|
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 07:10:19 +09:00
|
|
|
|
2022-02-06 23:31:03 +09:00
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with authorized fetch mode' do
|
|
|
|
let(:authorized_fetch_mode) { true }
|
2023-02-19 07:10:19 +09:00
|
|
|
|
2022-02-06 23:31:03 +09:00
|
|
|
it_behaves_like 'shared behavior'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|