Add specs for activitypub collections controller (#9484)
* Add specs for ActivityPub::CollectionsController#show * Raise ActiveRecord::RecordNotFound Raising ActiveRecord::NotFound raises NameError: uninitialized constant ActiveRecord::NotFound.
This commit is contained in:
parent
6eae8f77af
commit
ed24bb2c3e
@ -31,7 +31,7 @@ class ActivityPub::CollectionsController < Api::BaseController
|
|||||||
when 'featured'
|
when 'featured'
|
||||||
@account.pinned_statuses.count
|
@account.pinned_statuses.count
|
||||||
else
|
else
|
||||||
raise ActiveRecord::NotFound
|
raise ActiveRecord::RecordNotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class ActivityPub::CollectionsController < Api::BaseController
|
|||||||
scope.merge!(@account.pinned_statuses)
|
scope.merge!(@account.pinned_statuses)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise ActiveRecord::NotFound
|
raise ActiveRecord::RecordNotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
25
spec/controllers/activitypub/collections_controller_spec.rb
Normal file
25
spec/controllers/activitypub/collections_controller_spec.rb
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user