Commit b9f57192 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove reduntant `move_to_store` override

parent 99ee8228
......@@ -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
......@@ -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
......@@ -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
......
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