Move `api/v1/admin/trends/links/preview_card_providers` to request spec (#28951)
This commit is contained in:
parent
b6baab447d
commit
5119fbc9b7
|
@ -2,31 +2,26 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::V1::Admin::Trends::Links::PreviewCardProvidersController do
|
||||
render_views
|
||||
|
||||
describe 'API V1 Admin Trends Links Preview Card Providers' do
|
||||
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(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:preview_card_provider) { Fabricate(:preview_card_provider) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
describe 'GET /api/v1/admin/trends/links/publishers' do
|
||||
it 'returns http success' do
|
||||
get :index, params: { account_id: account.id, limit: 2 }
|
||||
get '/api/v1/admin/trends/links/publishers', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #approve' do
|
||||
describe 'POST /api/v1/admin/trends/links/publishers/:id/approve' do
|
||||
before do
|
||||
post :approve, params: { id: preview_card_provider.id }
|
||||
post "/api/v1/admin/trends/links/publishers/#{preview_card_provider.id}/approve", headers: headers
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||
|
@ -37,9 +32,9 @@ describe Api::V1::Admin::Trends::Links::PreviewCardProvidersController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'POST #reject' do
|
||||
describe 'POST /api/v1/admin/trends/links/publishers/:id/reject' do
|
||||
before do
|
||||
post :reject, params: { id: preview_card_provider.id }
|
||||
post "/api/v1/admin/trends/links/publishers/#{preview_card_provider.id}/reject", headers: headers
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
Loading…
Reference in New Issue