Commit 77f06178 authored by Micaël Bergeron's avatar Micaël Bergeron

remove a path building method only used in the specs

parent 5df8efac
......@@ -56,16 +56,6 @@ class FileUploader < GitlabUploader
end
end
# Auxiliary method to build dynamic path segment when not using a project model
#
# Prefer to use the `.model_path_segment` as it includes Hashed Storage specific logic
#
# TODO: review this path?
# TODO: remove me this makes no sense
def self.dynamic_path_builder(path)
File.join(root, path)
end
def self.upload_path(secret, identifier)
File.join(secret, identifier)
end
......
......@@ -15,7 +15,7 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
context 'on success' do
before do
TestEnv.clean_test_path
FileUtils.mkdir_p(FileUploader.dynamic_path_builder(old_attachments_path))
FileUtils.mkdir_p(File.join(FileUploader.root, old_attachments_path))
end
it 'returns true' do
......
......@@ -45,45 +45,6 @@ describe Upload do
end
end
describe '.remove_path' do
it 'removes all records at the given path' do
described_class.create!(
size: File.size(__FILE__),
path: __FILE__,
model: build_stubbed(:user),
uploader: 'AvatarUploader'
)
expect { described_class.remove_path(__FILE__) }
.to change { described_class.count }.from(1).to(0)
end
end
describe '.record' do
let(:fake_uploader) do
double(
file: double(size: 12_345),
upload_path: 'foo/bar.jpg',
model: build_stubbed(:user),
class: 'AvatarUploader',
upload: nil
)
end
it 'creates a new record and assigns size, path, model, and uploader' do
upload = described_class.record(fake_uploader)
aggregate_failures do
expect(upload).to be_persisted
expect(upload.size).to eq fake_uploader.file.size
expect(upload.path).to eq fake_uploader.upload_path
expect(upload.model_id).to eq fake_uploader.model.id
expect(upload.model_type).to eq fake_uploader.model.class.to_s
expect(upload.uploader).to eq fake_uploader.class
end
end
end
describe '#absolute_path' do
it 'returns the path directly when already absolute' do
path = '/path/to/namespace/project/secret/file.jpg'
......
......@@ -58,6 +58,6 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
end
def base_path(storage)
FileUploader.dynamic_path_builder(storage.disk_path)
File.join(FileUploader.root, storage.disk_path)
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