From 78347d25567b1b8cf2cb9e1fd4cab002fd6aff59 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 11 Dec 2023 02:55:45 -0500 Subject: [PATCH] Controller spec to request spec: `api/v1/accounts/familiar_followers` (#28305) --- .../v1/accounts/familiar_followers_spec.rb} | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) rename spec/{controllers/api/v1/accounts/familiar_followers_controller_spec.rb => requests/api/v1/accounts/familiar_followers_spec.rb} (53%) diff --git a/spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb b/spec/requests/api/v1/accounts/familiar_followers_spec.rb similarity index 53% rename from spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb rename to spec/requests/api/v1/accounts/familiar_followers_spec.rb index 3c7c7e8b8..fdc0a3a93 100644 --- a/spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb +++ b/spec/requests/api/v1/accounts/familiar_followers_spec.rb @@ -2,20 +2,16 @@ require 'rails_helper' -describe Api::V1::Accounts::FamiliarFollowersController do - render_views - - let(:user) { Fabricate(:user) } - let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') } +describe 'Accounts Familiar Followers API' do + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } + let(:scopes) { 'read:follows' } + let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } let(:account) { Fabricate(:account) } - before do - allow(controller).to receive(:doorkeeper_token) { token } - end - - describe 'GET #index' do + describe 'GET /api/v1/accounts/familiar_followers' do it 'returns http success' do - get :index, params: { account_id: account.id, limit: 2 } + get '/api/v1/accounts/familiar_followers', params: { account_id: account.id, limit: 2 }, headers: headers expect(response).to have_http_status(200) end @@ -26,7 +22,7 @@ describe Api::V1::Accounts::FamiliarFollowersController do it 'removes duplicate account IDs from params' do account_ids = [account_a, account_b, account_b, account_a, account_a].map { |a| a.id.to_s } - get :index, params: { id: account_ids } + get '/api/v1/accounts/familiar_followers', params: { id: account_ids }, headers: headers expect(body_as_json.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s) end