This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix instance actor not being dereferenceable (mastodon#17457)
* Add tests * Fix instance actor not being dereferenceable * Fix tests * Fix tests for real
- Loading branch information
1 parent
097c490
commit 92658f0
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe InstanceActorsController, type: :controller do | ||
describe 'GET #show' do | ||
context 'as JSON' do | ||
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 | ||
expect(response.headers['Set-Cookies']).to be nil | ||
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 } | ||
it_behaves_like 'shared behavior' | ||
end | ||
|
||
context 'with authorized fetch mode' do | ||
let(:authorized_fetch_mode) { true } | ||
it_behaves_like 'shared behavior' | ||
end | ||
end | ||
end | ||
end |