v4.1.4 #23

Merged
asonix merged 8 commits from asonix/changes into asonix/downstream 2023-07-07 19:55:23 +00:00
3 changed files with 19 additions and 1 deletions
Showing only changes of commit 53b979d5c7 - Show all commits

View file

@ -24,7 +24,7 @@ module Attachmentable
def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicateName
super(name, options)
send(:"before_#{name}_validate") do
send(:"before_#{name}_validate", prepend: true) do
attachment = send(name)
check_image_dimension(attachment)
set_file_content_type(attachment)

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Media API', paperclip_processing: true do
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:scopes) { 'write' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'POST /api/v2/media' do
it 'returns http success' do
post '/api/v2/media', headers: headers, params: { file: fixture_file_upload('attachment-jpg.123456_abcd', 'image/jpeg') }
expect(File.exist?(user.account.media_attachments.first.file.path(:small))).to be true
expect(response).to have_http_status(200)
end
end
end