mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-30 00:30:40 +00:00
53 lines
1.3 KiB
Ruby
53 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Api::V1::Admin::Trends::LinksController do
|
|
render_views
|
|
|
|
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) }
|
|
let(:account) { Fabricate(:account) }
|
|
let(:preview_card) { Fabricate(:preview_card) }
|
|
|
|
before do
|
|
allow(controller).to receive(:doorkeeper_token) { token }
|
|
end
|
|
|
|
describe 'GET #index' do
|
|
it 'returns http success' do
|
|
get :index, params: { account_id: account.id, limit: 2 }
|
|
|
|
expect(response).to have_http_status(200)
|
|
end
|
|
end
|
|
|
|
describe 'POST #approve' do
|
|
before do
|
|
post :approve, params: { id: preview_card.id }
|
|
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
|
|
|
|
describe 'POST #reject' do
|
|
before do
|
|
post :reject, params: { id: preview_card.id }
|
|
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
|
|
end
|