summaryrefslogtreecommitdiff
path: root/spec/uploaders
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-05-03 17:26:49 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-05-31 07:17:03 +0200
commit4464c22d6d23d893494682d309aec3fb31c11ae3 (patch)
treecb7490034185f79c88db472650b87afdcdbafa3f /spec/uploaders
parent8039b9c3c6caedc19e0e44d086a007e8975134b7 (diff)
downloadgitlab-ce-4464c22d6d23d893494682d309aec3fb31c11ae3.tar.gz
Support descriptions for snippets
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/file_mover_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/uploaders/file_mover_spec.rb b/spec/uploaders/file_mover_spec.rb
new file mode 100644
index 00000000000..99d50e78240
--- /dev/null
+++ b/spec/uploaders/file_mover_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe FileMover do
+ let(:filename) { 'banana_sample.gif' }
+ let(:file) { fixture_file_upload(Rails.root.join('spec', 'fixtures', filename)) }
+ let(:temp_description) { 'test ![banana_sample](/uploads/temp/secret55/banana_sample.gif)' }
+ let(:temp_file_path) { File.join('secret55', filename).to_s }
+ let(:file_path) { File.join('uploads', 'personal_snippet', snippet.id.to_s, 'secret55', filename).to_s }
+
+ let(:snippet) { create(:personal_snippet, description: temp_description) }
+
+ subject { described_class.new(file_path, snippet).execute }
+
+ describe '#execute' do
+ it 'updates the description correctly' do
+ expect(FileUtils).to receive(:mkdir_p).with(a_string_including(file_path))
+ expect(FileUtils).to receive(:move).with(a_string_including(temp_file_path), a_string_including(file_path))
+
+ subject
+
+ expect(snippet.reload.description)
+ .to eq("test ![banana_sample](/uploads/personal_snippet/#{snippet.id}/secret55/banana_sample.gif)")
+ end
+ end
+end