2023-11-22 01:25:07 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 15:12:25 +10:00
|
|
|
RSpec.describe 'Admin Measures' do
|
2023-11-22 01:25:07 +11:00
|
|
|
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
|
|
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
|
|
|
let(:account) { Fabricate(:account) }
|
2024-06-19 02:04:58 +10:00
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
keys: %w(instance_accounts instance_follows instance_followers),
|
|
|
|
instance_accounts: {
|
|
|
|
domain: 'mastodon.social',
|
|
|
|
include_subdomains: true,
|
|
|
|
},
|
|
|
|
instance_follows: {
|
|
|
|
domain: 'mastodon.social',
|
|
|
|
include_subdomains: true,
|
|
|
|
},
|
|
|
|
instance_followers: {
|
|
|
|
domain: 'mastodon.social',
|
|
|
|
include_subdomains: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
2023-11-22 01:25:07 +11:00
|
|
|
|
|
|
|
describe 'GET /api/v1/admin/measures' do
|
|
|
|
context 'when not authorized' do
|
|
|
|
it 'returns http forbidden' do
|
2024-06-19 02:04:58 +10:00
|
|
|
post '/api/v1/admin/measures', params: params
|
2023-11-22 01:25:07 +11:00
|
|
|
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with correct scope' do
|
|
|
|
let(:scopes) { 'admin:read' }
|
|
|
|
|
|
|
|
it 'returns http success and status json' do
|
2024-06-19 02:04:58 +10:00
|
|
|
post '/api/v1/admin/measures', params: params, headers: headers
|
2023-11-22 01:25:07 +11:00
|
|
|
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
|
2024-09-06 19:58:46 +10:00
|
|
|
expect(response.parsed_body)
|
2023-11-22 01:25:07 +11:00
|
|
|
.to be_an(Array)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|