diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-29 10:54:35 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-06-07 08:52:41 +0300 |
commit | 2e311d9d1aac58bbd9c7d6c97c7cbcccf2715347 (patch) | |
tree | 04555ee940d5488ef6d44c5ad3afa0688cd6c1c5 /spec/controllers | |
parent | 4464c22d6d23d893494682d309aec3fb31c11ae3 (diff) |
Support uploads for newly created personal snippets
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/uploads_controller_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index 8000c9dec61..01a0659479b 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -92,6 +92,40 @@ describe UploadsController do end end end + + context 'temporal with valid image' do + subject do + post :create, model: 'personal_snippet', file: jpg, format: :json + end + + it 'returns a content with original filename, new link, and correct type.' do + subject + + expect(response.body).to match '\"alt\":\"rails_sample\"' + expect(response.body).to match "\"url\":\"/uploads/temp" + end + + it 'does not create an Upload record' do + expect { subject }.not_to change { Upload.count } + end + end + + context 'temporal with valid non-image file' do + subject do + post :create, model: 'personal_snippet', file: txt, format: :json + end + + it 'returns a content with original filename, new link, and correct type.' do + subject + + expect(response.body).to match '\"alt\":\"doc_sample.txt\"' + expect(response.body).to match "\"url\":\"/uploads/temp" + end + + it 'does not create an Upload record' do + expect { subject }.not_to change { Upload.count } + end + end end end |