2023-03-05 03:12:54 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-03-02 03:24:45 +11:00
|
|
|
describe 'API V1 Admin Trends Statuses' do
|
2023-04-18 19:33:30 +10:00
|
|
|
let(:role) { UserRole.find_by(name: 'Admin') }
|
|
|
|
let(:user) { Fabricate(:user, role: role) }
|
|
|
|
let(:scopes) { 'admin:read admin:write' }
|
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
2023-03-05 03:12:54 +11:00
|
|
|
let(:account) { Fabricate(:account) }
|
2023-04-18 19:33:30 +10:00
|
|
|
let(:status) { Fabricate(:status) }
|
2024-03-02 03:24:45 +11:00
|
|
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
2023-03-05 03:12:54 +11:00
|
|
|
|
2024-03-02 03:24:45 +11:00
|
|
|
describe 'GET /api/v1/admin/trends/statuses' do
|
2023-03-05 03:12:54 +11:00
|
|
|
it 'returns http success' do
|
2024-03-02 03:24:45 +11:00
|
|
|
get '/api/v1/admin/trends/statuses', params: { account_id: account.id, limit: 2 }, headers: headers
|
2023-03-05 03:12:54 +11:00
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
2023-04-18 19:33:30 +10:00
|
|
|
|
2024-03-02 03:24:45 +11:00
|
|
|
describe 'POST /api/v1/admin/trends/statuses/:id/approve' do
|
2023-04-18 19:33:30 +10:00
|
|
|
before do
|
2024-03-02 03:24:45 +11:00
|
|
|
post "/api/v1/admin/trends/statuses/#{status.id}/approve", headers: headers
|
2023-04-18 19:33:30 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
|
|
|
it_behaves_like 'forbidden for wrong role', ''
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-03-02 03:24:45 +11:00
|
|
|
describe 'POST /api/v1/admin/trends/statuses/:id/unapprove' do
|
2023-04-18 19:33:30 +10:00
|
|
|
before do
|
2024-03-02 03:24:45 +11:00
|
|
|
post "/api/v1/admin/trends/statuses/#{status.id}/reject", headers: headers
|
2023-04-18 19:33:30 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
|
|
|
it_behaves_like 'forbidden for wrong role', ''
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
2023-03-05 03:12:54 +11:00
|
|
|
end
|