From 0b0ca6f3b85c9d08e4642e49d743f8d060632293 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 26 Jan 2024 12:40:15 -0500 Subject: [PATCH] Move `api/v1/timelines/list` to request spec (#28948) --- .../api/v1/timelines/list_spec.rb} | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) rename spec/{controllers/api/v1/timelines/list_controller_spec.rb => requests/api/v1/timelines/list_spec.rb} (73%) diff --git a/spec/controllers/api/v1/timelines/list_controller_spec.rb b/spec/requests/api/v1/timelines/list_spec.rb similarity index 73% rename from spec/controllers/api/v1/timelines/list_controller_spec.rb rename to spec/requests/api/v1/timelines/list_spec.rb index 4ef5d41af8..98d2456745 100644 --- a/spec/controllers/api/v1/timelines/list_controller_spec.rb +++ b/spec/requests/api/v1/timelines/list_spec.rb @@ -2,20 +2,17 @@ require 'rails_helper' -describe Api::V1::Timelines::ListController do - render_views - +describe 'API V1 Timelines List' do let(:user) { Fabricate(:user) } + let(:scopes) { 'read:statuses' } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } + let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } let(:list) { Fabricate(:list, account: user.account) } - before do - allow(controller).to receive(:doorkeeper_token) { token } - end - context 'with a user context' do let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:lists') } - describe 'GET #show' do + describe 'GET /api/v1/timelines/list/:id' do before do follow = Fabricate(:follow, account: user.account) list.accounts << follow.target_account @@ -23,7 +20,8 @@ describe Api::V1::Timelines::ListController do end it 'returns http success' do - get :show, params: { id: list.id } + get "/api/v1/timelines/list/#{list.id}", headers: headers + expect(response).to have_http_status(200) end end @@ -35,7 +33,8 @@ describe Api::V1::Timelines::ListController do describe 'GET #show' do it 'returns http not found' do - get :show, params: { id: list.id } + get "/api/v1/timelines/list/#{list.id}", headers: headers + expect(response).to have_http_status(404) end end @@ -46,7 +45,7 @@ describe Api::V1::Timelines::ListController do describe 'GET #show' do it 'returns http unprocessable entity' do - get :show, params: { id: list.id } + get "/api/v1/timelines/list/#{list.id}", headers: headers expect(response).to have_http_status(422) expect(response.headers['Link']).to be_nil