diff options
author | Robert Speicher <robert@gitlab.com> | 2018-09-13 14:53:05 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-09-13 14:53:05 +0000 |
commit | c7d1eef671dbf598814a6c2ff1f81b924583ae8a (patch) | |
tree | 23988df1d29e933943858a66821ba7f493976b3e /app/uploaders | |
parent | ff5d8b635f234241441009e41af7b61f5804b2c2 (diff) | |
parent | 2039c8280db1646845c33d6c5a74e5f23ca6f4de (diff) | |
download | gitlab-ce-c7d1eef671dbf598814a6c2ff1f81b924583ae8a.tar.gz |
Merge branch 'rubocop-code-reuse' into 'master'
Add RuboCop cops to enforce code reusing rules
See merge request gitlab-org/gitlab-ce!21391
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/records_uploads.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/uploaders/records_uploads.rb b/app/uploaders/records_uploads.rb index 5795065ae11..0efca895a50 100644 --- a/app/uploaders/records_uploads.rb +++ b/app/uploaders/records_uploads.rb @@ -18,6 +18,7 @@ module RecordsUploads # `Tempfile` object the callback gets. # # Called `after :store` + # rubocop: disable CodeReuse/ActiveRecord def record_upload(_tempfile = nil) return unless model return unless file && file.exists? @@ -29,6 +30,7 @@ module RecordsUploads self.upload = build_upload.tap(&:save!) end end + # rubocop: enable CodeReuse/ActiveRecord def upload_path File.join(store_dir, filename.to_s) @@ -36,9 +38,11 @@ module RecordsUploads private + # rubocop: disable CodeReuse/ActiveRecord def uploads Upload.order(id: :desc).where(uploader: self.class.to_s) end + # rubocop: enable CodeReuse/ActiveRecord def build_upload Upload.new( @@ -53,11 +57,13 @@ module RecordsUploads # Before removing an attachment, destroy any Upload records at the same path # # Called `before :remove` + # rubocop: disable CodeReuse/ActiveRecord def destroy_upload(*args) return unless file && file.exists? self.upload = nil uploads.where(path: upload_path).delete_all end + # rubocop: enable CodeReuse/ActiveRecord end end |