media_spec.rb 701 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Media API', paperclip_processing: true do
  4. let(:user) { Fabricate(:user) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
  6. let(:scopes) { 'write' }
  7. let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
  8. describe 'POST /api/v2/media' do
  9. it 'returns http success' do
  10. post '/api/v2/media', headers: headers, params: { file: fixture_file_upload('attachment-jpg.123456_abcd', 'image/jpeg') }
  11. expect(File.exist?(user.account.media_attachments.first.file.path(:small))).to be true
  12. expect(response).to have_http_status(200)
  13. end
  14. end
  15. end