diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-01 15:14:35 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-02 15:22:24 +0200 |
commit | 43ff7386411af0f538710f3627622f71e5e34472 (patch) | |
tree | 3bb4d32c1389504d70395f36e8e223899fcbccd5 /spec/uploaders | |
parent | 6277bda61c511696f9d12fae4238b5214a722571 (diff) | |
download | gitlab-ce-43ff7386411af0f538710f3627622f71e5e34472.tar.gz |
Support uploaders for personal snippets comments12910-uploader-pers-snippet
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/personal_file_uploader_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/uploaders/personal_file_uploader_spec.rb b/spec/uploaders/personal_file_uploader_spec.rb new file mode 100644 index 00000000000..fb92f2ae3ab --- /dev/null +++ b/spec/uploaders/personal_file_uploader_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe PersonalFileUploader do + let(:uploader) { described_class.new(build_stubbed(:empty_project)) } + let(:snippet) { create(:personal_snippet) } + + describe '.absolute_path' do + it 'returns the correct absolute path by building it dynamically' do + upload = double(model: snippet, path: 'secret/foo.jpg') + + dynamic_segment = "personal_snippet/#{snippet.id}" + + expect(described_class.absolute_path(upload)).to end_with("#{dynamic_segment}/secret/foo.jpg") + end + end + + describe '#to_h' do + it 'returns the hass' do + uploader = described_class.new(snippet, 'secret') + + allow(uploader).to receive(:file).and_return(double(extension: 'txt', filename: 'file_name')) + expected_url = "/uploads/personal_snippet/#{snippet.id}/secret/file_name" + + expect(uploader.to_h).to eq( + alt: 'file_name', + url: expected_url, + markdown: "[file_name](#{expected_url})" + ) + end + end +end |