Remove reduntant move_to_store override

This commit is contained in:
Grzegorz Bizon 2016-03-30 12:11:27 +02:00
parent 99ee822857
commit b9f5719285
3 changed files with 10 additions and 16 deletions

View file

@ -24,10 +24,6 @@ class FileUploader < CarrierWave::Uploader::Base
File.join(base_dir, 'tmp', @project.path_with_namespace, @secret)
end
def self.generate_secret
SecureRandom.hex
end
def secure_url
File.join("/uploads", @secret, file.filename)
end
@ -50,4 +46,8 @@ class FileUploader < CarrierWave::Uploader::Base
markdown: markdown
}
end
def self.generate_secret
SecureRandom.hex
end
end

View file

@ -17,11 +17,11 @@ module Gitlab
def rewrite(target_project)
return @text unless needs_rewrite?
new_uploader = file_uploader(target_project)
@text.gsub(@pattern) do |markdown|
file = find_file(@source_project, $~[:secret], $~[:file])
return markdown unless file.try(:exists?)
new_uploader = FileUploader.new(target_project)
new_uploader.store!(file)
new_uploader.to_markdown
end
@ -42,16 +42,10 @@ module Gitlab
private
def find_file(project, secret, file)
uploader = file_uploader(project, secret)
uploader = FileUploader.new(project, secret)
uploader.retrieve_from_store!(file)
uploader.file
end
def file_uploader(project, secret = nil)
uploader = FileUploader.new(project, secret)
uploader.define_singleton_method(:move_to_store) { false }
uploader
end
end
end
end

View file

@ -8,13 +8,13 @@ describe Gitlab::Gfm::UploadsRewriter do
context 'text contains links to uploads' do
let(:uploader) { build(:file_uploader, project: old_project) }
let(:markdown) { uploader.to_h[:markdown] }
let(:text) { "Text and #{markdown}"}
let(:text) { "Text and #{uploader.to_markdown}"}
describe '#rewrite' do
let!(:new_text) { rewriter.rewrite(new_project) }
let(:new_rewriter) { described_class.new(new_text, new_project, user) }
let(:old_file) { rewriter.files.first }
let(:old_file) { uploader.file }
let(:new_file) { new_rewriter.files.first }
it 'rewrites content' do
@ -29,7 +29,7 @@ describe Gitlab::Gfm::UploadsRewriter do
end
it 'does not remove old files' do
expect(old_file.exists?).to be true
expect(old_file).to exist
end
end