The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
895 B

  1. require 'rails_helper'
  2. RSpec.describe Api::MediaController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. let(:token) { double acceptable?: true, resource_owner_id: user.id }
  6. before do
  7. allow(controller).to receive(:doorkeeper_token) { token }
  8. end
  9. describe 'POST #create' do
  10. before do
  11. post :create, params: { file: fixture_file_upload('files/attachment.jpg', 'image/jpeg') }
  12. end
  13. it 'returns http success' do
  14. expect(response).to have_http_status(:success)
  15. end
  16. it 'creates a media attachment' do
  17. expect(MediaAttachment.first).to_not be_nil
  18. end
  19. it 'uploads a file' do
  20. expect(MediaAttachment.first).to have_attached_file(:file)
  21. end
  22. it 'returns media ID in JSON' do
  23. expect(body_as_json[:id]).to eq MediaAttachment.first.id
  24. end
  25. end
  26. end