about summary refs log tree commit diff
path: root/spec/controllers/activitypub/inboxes_controller_spec.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-05-03 16:30:36 +0200
committerGitHub <noreply@github.com>2020-05-03 16:30:36 +0200
commit988b0493fea7a850130b83d0e81675bda8dd9d8e (patch)
tree0d9cdb503c8f0fe131e01cfdbf61ab85dcd1f296 /spec/controllers/activitypub/inboxes_controller_spec.rb
parenta1062df1e1bc15d32a3afe3054d1e0063a4beb93 (diff)
Add more tests for ActivityPub controllers (#13585)
Diffstat (limited to 'spec/controllers/activitypub/inboxes_controller_spec.rb')
-rw-r--r--spec/controllers/activitypub/inboxes_controller_spec.rb28
1 files changed, 17 insertions, 11 deletions
diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb
index a9ee75490..f3bc23953 100644
--- a/spec/controllers/activitypub/inboxes_controller_spec.rb
+++ b/spec/controllers/activitypub/inboxes_controller_spec.rb
@@ -3,25 +3,31 @@
 require 'rails_helper'
 
 RSpec.describe ActivityPub::InboxesController, type: :controller do
+  let(:remote_account) { nil }
+
+  before do
+    allow(controller).to receive(:signed_request_account).and_return(remote_account)
+  end
+
   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
+    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