0
0
Fork 0

Add more tests for ActivityPub controllers (#13585)

This commit is contained in:
Eugen Rochko 2020-05-03 16:30:36 +02:00 committed by GitHub
parent a1062df1e1
commit 988b0493fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1320 additions and 147 deletions

View file

@ -3,25 +3,31 @@
require 'rails_helper'
RSpec.describe ActivityPub::InboxesController, type: :controller do
describe 'POST #create' do
context 'with signed_request_account' do
it 'returns 202' do
allow(controller).to receive(:signed_request_account) do
Fabricate(:account)
end
let(:remote_account) { nil }
before do
allow(controller).to receive(:signed_request_account).and_return(remote_account)
end
describe 'POST #create' do
context 'with signature' do
let(:remote_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub) }
before do
post :create, body: '{}'
end
it 'returns http accepted' do
expect(response).to have_http_status(202)
end
end
context 'without signed_request_account' do
it 'returns 401' do
allow(controller).to receive(:signed_request_account) do
false
end
context 'without signature' do
before do
post :create, body: '{}'
end
it 'returns http not authorized' do
expect(response).to have_http_status(401)
end
end