FEATURE: generate (avatar) thumbnails in a background task

FIX: keep the "uploading..." indicator until the server replies via the MessageBus
FIX: text was disapearing when uploading an avatar

PERF: always use a region for S3 (defaults to 'us-east-1')
FEATURE: ApplyCDN middleware when using S3
FIX: use the same pattern to store files on S3 and locally
PERF: keep a local cache of uploads when generating thumbnails
FEATURE: migrate_to_s3 rake task
This commit is contained in:
Régis Hanol
2015-05-25 17:59:00 +02:00
parent 675e2c6e13
commit bb0c2813ac
22 changed files with 303 additions and 94 deletions

View File

@ -27,27 +27,35 @@ describe UploadsController do
end
it 'is successful with an image' do
Jobs.expects(:enqueue).with(:create_thumbnails, anything)
message = MessageBus.track_publish do
xhr :post, :create, file: logo, type: "composer"
xhr :post, :create, file: logo, type: "avatar"
end.first
expect(response.status).to eq 200
expect(message.channel).to eq("/uploads/composer")
expect(message.data).to be
end
it 'is successful with an attachment' do
message = MessageBus.track_publish do
xhr :post, :create, file: text_file, type: "avatar"
end.first
expect(response.status).to eq 200
expect(message.channel).to eq("/uploads/avatar")
expect(message.data).to be
end
it 'is successful with an attachment' do
SiteSetting.stubs(:authorized_extensions).returns("*")
Jobs.expects(:enqueue).never
message = MessageBus.track_publish do
xhr :post, :create, file: text_file, type: "composer"
end.first
expect(response.status).to eq 200
expect(message.channel).to eq("/uploads/composer")
expect(message.data).to be
end
it 'correctly sets retain_hours for admins' do
Jobs.expects(:enqueue).with(:create_thumbnails, anything)
log_in :admin
message = MessageBus.track_publish do
@ -61,6 +69,8 @@ describe UploadsController do
it 'properly returns errors' do
SiteSetting.stubs(:max_attachment_size_kb).returns(1)
Jobs.expects(:enqueue).never
message = MessageBus.track_publish do
xhr :post, :create, file: text_file, type: "avatar"
end.first