about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/activitypub/collections_controller.rb4
-rw-r--r--spec/controllers/activitypub/collections_controller_spec.rb25
2 files changed, 27 insertions, 2 deletions
diff --git a/app/controllers/activitypub/collections_controller.rb b/app/controllers/activitypub/collections_controller.rb
index 96bf901a7..995da9c55 100644
--- a/app/controllers/activitypub/collections_controller.rb
+++ b/app/controllers/activitypub/collections_controller.rb
@@ -31,7 +31,7 @@ class ActivityPub::CollectionsController < Api::BaseController
     when 'featured'
       @account.pinned_statuses.count
     else
-      raise ActiveRecord::NotFound
+      raise ActiveRecord::RecordNotFound
     end
   end
 
@@ -42,7 +42,7 @@ class ActivityPub::CollectionsController < Api::BaseController
         scope.merge!(@account.pinned_statuses)
       end
     else
-      raise ActiveRecord::NotFound
+      raise ActiveRecord::RecordNotFound
     end
   end
 
diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb
new file mode 100644
index 000000000..34114cc85
--- /dev/null
+++ b/spec/controllers/activitypub/collections_controller_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe ActivityPub::CollectionsController, type: :controller do
+  describe 'POST #show' do
+    let(:account) { Fabricate(:account) }
+
+    context 'id is "featured"' do
+      it 'returns 200 with "application/activity+json"' do
+        post :show, params: { id: 'featured', account_username: account.username }
+
+        expect(response).to have_http_status(200)
+        expect(response.content_type).to eq 'application/activity+json'
+      end
+    end
+
+    context 'id is not "featured"' do
+      it 'returns 404' do
+        post :show, params: { id: 'hoge', account_username: account.username }
+        expect(response).to have_http_status(404)
+      end
+    end
+  end
+end