gitlab-org--gitlab-foss/app/uploaders/avatar_uploader.rb
Robert Speicher a8c62dfe5c Minor refactoring of Uploaders
- Moves a duplicate `file_storage?` definition into the common
  `GitlabUploader` ancestor.
- Get the `uploads` base directory from a class method rather than
  hard-coding it where it's needed. This will be used in a subsequent MR
  to store Uploads in the database.
- Improves the specs for uploaders.
2017-02-24 16:41:27 -05:00

24 lines
511 B
Ruby

class AvatarUploader < GitlabUploader
include UploaderHelper
storage :file
def store_dir
"#{base_dir}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def exists?
model.avatar.file && model.avatar.file.exists?
end
# We set move_to_store and move_to_cache to 'false' to prevent stealing
# the avatar file from a project when forking it.
# https://gitlab.com/gitlab-org/gitlab-ce/issues/26158
def move_to_store
false
end
def move_to_cache
false
end
end