summaryrefslogtreecommitdiff
path: root/spec/uploaders/file_uploader_spec.rb
diff options
context:
space:
mode:
authorJarka Košanová <jarka@gitlab.com>2018-10-29 10:05:47 +0100
committerJarka Košanová <jarka@gitlab.com>2018-11-12 08:57:25 +0100
commit4af1712d01efb7295cc069dca0045b01c7b4cb40 (patch)
treed32a325b8d7e0a7ee00e032e8927e4ba9af9c29d /spec/uploaders/file_uploader_spec.rb
parent2e690c8208e9da5e7152e77cd77efdade5260be1 (diff)
downloadgitlab-ce-4af1712d01efb7295cc069dca0045b01c7b4cb40.tar.gz
Extract code from Issues::MoveServicece-3777-promote-to-epic
Extract code to make it easier reusable - introduce AttributesRewriter and ContentRewriter - support group entites when rewriting content - make Uploader copy_to working for Namespaces
Diffstat (limited to 'spec/uploaders/file_uploader_spec.rb')
-rw-r--r--spec/uploaders/file_uploader_spec.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
index 7e24efda5dd..c74e0bf1955 100644
--- a/spec/uploaders/file_uploader_spec.rb
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -81,19 +81,24 @@ describe FileUploader do
end
describe 'copy_to' do
+ let(:new_project) { create(:project) }
+ let(:moved) { described_class.copy_to(subject, new_project) }
+
shared_examples 'returns a valid uploader' do
describe 'returned uploader' do
- let(:new_project) { create(:project) }
- let(:moved) { described_class.copy_to(subject, new_project) }
-
it 'generates a new secret' do
expect(subject).to be
expect(described_class).to receive(:generate_secret).once.and_call_original
expect(moved).to be
end
- it 'create new upload' do
- expect(moved.upload).not_to eq(subject.upload)
+ it 'creates new upload correctly' do
+ upload = moved.upload
+
+ expect(upload).not_to eq(subject.upload)
+ expect(upload.model).to eq(new_project)
+ expect(upload.uploader).to eq('FileUploader')
+ expect(upload.secret).not_to eq(subject.upload.secret)
end
it 'copies the file' do
@@ -111,6 +116,12 @@ describe FileUploader do
end
include_examples 'returns a valid uploader'
+
+ it 'copies the file to the correct location' do
+ expect(moved.upload.path).to eq("#{moved.upload.secret}/dk.png")
+ expect(moved.file.path).to end_with("public/uploads/#{new_project.disk_path}/#{moved.upload.secret}/dk.png")
+ expect(moved.filename).to eq('dk.png')
+ end
end
context 'files are stored remotely' do
@@ -121,6 +132,12 @@ describe FileUploader do
end
include_examples 'returns a valid uploader'
+
+ it 'copies the file to the correct location' do
+ expect(moved.upload.path).to eq("#{new_project.disk_path}/#{moved.upload.secret}/dk.png")
+ expect(moved.file.path).to eq("#{new_project.disk_path}/#{moved.upload.secret}/dk.png")
+ expect(moved.filename).to eq('dk.png')
+ end
end
end