mastodon/spec/support/api_authentication.rb
David Roetzel d2f82d402a
Add shared context for API authentication
And use it in request specs.
2025-11-21 16:18:28 +01:00

9 lines
375 B
Ruby

# frozen_string_literal: true
RSpec.shared_context 'with API authentication' do |oauth_scopes: '', user_fabricator: :user|
let(:user) { Fabricate(user_fabricator) }
let(:scopes) { oauth_scopes }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
end