Commit c3bf1e21 authored by Stan Hu's avatar Stan Hu

Geo: Fix attachments/avatars saving to the wrong directory

Closes #3634
parent 90f19538
---
title: 'Geo: Fix attachments/avatars saving to the wrong directory'
merge_request:
author:
type: fixed
...@@ -2,9 +2,11 @@ module Gitlab ...@@ -2,9 +2,11 @@ module Gitlab
module Geo module Geo
class FileTransfer < Transfer class FileTransfer < Transfer
def initialize(file_type, upload) def initialize(file_type, upload)
uploader = upload.uploader.constantize
@file_type = file_type @file_type = file_type
@file_id = upload.id @file_id = upload.id
@filename = upload.path @filename = uploader.absolute_path(upload)
@request_data = build_request_data(upload) @request_data = build_request_data(upload)
end end
......
require 'spec_helper'
describe Gitlab::Geo::FileTransfer do
let(:user) { create(:user, avatar: fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/png')) }
let(:upload) { Upload.find_by(model: user, uploader: 'AvatarUploader') }
subject { described_class.new(:file, upload) }
describe '#execute' do
context 'user avatar' do
it 'sets an absolute path' do
expect(subject.file_type).to eq(:file)
expect(subject.file_id).to eq(upload.id)
expect(subject.filename).to eq(AvatarUploader.absolute_path(upload))
expect(Pathname.new(subject.filename).absolute?).to be_truthy
expect(subject.request_data).to eq({ id: upload.id,
type: 'User',
checksum: upload.checksum })
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment