From b6baab447de9c394d93d5d0b9800b4a4dab28cd7 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 26 Jan 2024 12:41:13 -0500 Subject: [PATCH] Move `api/v2/admin/accounts` to request spec (#28950) --- .../api/v2/admin/accounts_spec.rb} | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) rename spec/{controllers/api/v2/admin/accounts_controller_spec.rb => requests/api/v2/admin/accounts_spec.rb} (94%) diff --git a/spec/controllers/api/v2/admin/accounts_controller_spec.rb b/spec/requests/api/v2/admin/accounts_spec.rb similarity index 94% rename from spec/controllers/api/v2/admin/accounts_controller_spec.rb rename to spec/requests/api/v2/admin/accounts_spec.rb index 349f4d2528..fb04850bb7 100644 --- a/spec/controllers/api/v2/admin/accounts_controller_spec.rb +++ b/spec/requests/api/v2/admin/accounts_spec.rb @@ -2,19 +2,14 @@ require 'rails_helper' -RSpec.describe Api::V2::Admin::AccountsController do - render_views - +RSpec.describe 'API V2 Admin Accounts' do let(:role) { UserRole.find_by(name: 'Moderator') } 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) } - before do - allow(controller).to receive(:doorkeeper_token) { token } - end - describe 'GET #index' do let!(:remote_account) { Fabricate(:account, domain: 'example.org') } let!(:other_remote_account) { Fabricate(:account, domain: 'foo.bar') } @@ -28,7 +23,8 @@ RSpec.describe Api::V2::Admin::AccountsController do before do pending_account.user.update(approved: false) - get :index, params: params + + get '/api/v2/admin/accounts', params: params, headers: headers end it_behaves_like 'forbidden for wrong scope', 'write:statuses'