From 5694334fc60eb44ad8311d42c998594fc800baac Mon Sep 17 00:00:00 2001 From: Adam Sharp Date: Tue, 13 Feb 2024 13:22:28 +0000 Subject: [PATCH] Fix tests --- .../subject_access_requests_controller_show_spec.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/spec/requests/api/subject_access_requests_controller_show_spec.rb b/spec/requests/api/subject_access_requests_controller_show_spec.rb index b0e5dc4df..907dddd7b 100644 --- a/spec/requests/api/subject_access_requests_controller_show_spec.rb +++ b/spec/requests/api/subject_access_requests_controller_show_spec.rb @@ -3,11 +3,6 @@ require 'rails_helper' RSpec.describe SubjectAccessRequestsController do - let(:access_token) { 'spoofed-token' } - let(:headers) { { 'CONTENT_TYPE': content_type }.merge('Authorization' => "Bearer #{access_token}") } - let(:response_json) { JSON.parse(response.body) } - let(:content_type) { ApiController::CONTENT_TYPE } - describe 'GET /subject-access-request' do subject(:get_sar) { get '/subject-access-request', params:, headers: } @@ -15,10 +10,10 @@ let(:params) { {} } let(:application) { Doorkeeper::Application.create(name: 'test') } let(:doorkeeper_token) { Doorkeeper::AccessToken.create(application:, scopes: 'subject-access-request') } - - before do - allow(controller).to receive(:doorkeeper_token).and_return(doorkeeper_token) - end + let(:access_token) { doorkeeper_token.token } + let(:headers) { { 'CONTENT_TYPE': content_type }.merge('Authorization' => "Bearer #{access_token}") } + let(:response_json) { JSON.parse(response.body) } + let(:content_type) { ApiController::CONTENT_TYPE } context 'when the token is missing the subject-access-request scope' do let(:doorkeeper_token) { Doorkeeper::AccessToken.create(application:) }