Use the Hashed Storage compatible layer to store Attachments
This commit is contained in:
parent
b19076948d
commit
c06eb779a3
|
@ -30,7 +30,7 @@ class FileUploader < GitlabUploader
|
||||||
#
|
#
|
||||||
# Returns a String without a trailing slash
|
# Returns a String without a trailing slash
|
||||||
def self.dynamic_path_segment(model)
|
def self.dynamic_path_segment(model)
|
||||||
File.join(CarrierWave.root, base_dir, model.full_path)
|
File.join(CarrierWave.root, base_dir, model.disk_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :model
|
attr_accessor :model
|
||||||
|
|
|
@ -3,25 +3,51 @@ require 'spec_helper'
|
||||||
describe FileUploader do
|
describe FileUploader do
|
||||||
let(:uploader) { described_class.new(build_stubbed(:project)) }
|
let(:uploader) { described_class.new(build_stubbed(:project)) }
|
||||||
|
|
||||||
describe '.absolute_path' do
|
context 'legacy storage' do
|
||||||
it 'returns the correct absolute path by building it dynamically' do
|
let(:project) { build_stubbed(:project) }
|
||||||
project = build_stubbed(:project)
|
|
||||||
upload = double(model: project, path: 'secret/foo.jpg')
|
|
||||||
|
|
||||||
dynamic_segment = project.path_with_namespace
|
describe '.absolute_path' do
|
||||||
|
it 'returns the correct absolute path by building it dynamically' do
|
||||||
|
upload = double(model: project, path: 'secret/foo.jpg')
|
||||||
|
|
||||||
expect(described_class.absolute_path(upload))
|
dynamic_segment = project.full_path
|
||||||
.to end_with("#{dynamic_segment}/secret/foo.jpg")
|
|
||||||
|
expect(described_class.absolute_path(upload))
|
||||||
|
.to end_with("#{dynamic_segment}/secret/foo.jpg")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#store_dir" do
|
||||||
|
it "stores in the namespace path" do
|
||||||
|
uploader = described_class.new(project)
|
||||||
|
|
||||||
|
expect(uploader.store_dir).to include(project.full_path)
|
||||||
|
expect(uploader.store_dir).not_to include("system")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#store_dir" do
|
context 'hashed storage' do
|
||||||
it "stores in the namespace path" do
|
let(:project) { build_stubbed(:project, :hashed) }
|
||||||
project = build_stubbed(:project)
|
|
||||||
uploader = described_class.new(project)
|
|
||||||
|
|
||||||
expect(uploader.store_dir).to include(project.path_with_namespace)
|
describe '.absolute_path' do
|
||||||
expect(uploader.store_dir).not_to include("system")
|
it 'returns the correct absolute path by building it dynamically' do
|
||||||
|
upload = double(model: project, path: 'secret/foo.jpg')
|
||||||
|
|
||||||
|
dynamic_segment = project.disk_path
|
||||||
|
|
||||||
|
expect(described_class.absolute_path(upload))
|
||||||
|
.to end_with("#{dynamic_segment}/secret/foo.jpg")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#store_dir" do
|
||||||
|
it "stores in the namespace path" do
|
||||||
|
uploader = described_class.new(project)
|
||||||
|
|
||||||
|
expect(uploader.store_dir).to include(project.disk_path)
|
||||||
|
expect(uploader.store_dir).not_to include("system")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue