diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 00:09:34 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 00:09:34 +0000 |
commit | 3cd08f4bf96cda3e9d3abf233095107832b17c20 (patch) | |
tree | dc09a618783a79d70f2a404374d4b850ccf9cc84 /spec/models/upload_spec.rb | |
parent | dd4bee69b7d55620f7dc9db8c36b478bd4959755 (diff) | |
download | gitlab-ce-3cd08f4bf96cda3e9d3abf233095107832b17c20.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/upload_spec.rb')
-rw-r--r-- | spec/models/upload_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index 7138305d7b1..8a64948d570 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -127,6 +127,36 @@ describe Upload do expect(uploader.mounted_as).to eq(subject.send(:mount_point)) expect(uploader.file).not_to be_nil end + + context 'when upload has mount_point nil' do + context 'when an upload belongs to a note' do + it 'mounts it as attachment' do + project = create(:project, :legacy_storage) + merge_request = create(:merge_request, source_project: project) + note = create(:legacy_diff_note_on_merge_request, note: 'some note', project: project, noteable: merge_request) + + subject = build(:upload, :with_file, :attachment_upload, model: note, mount_point: nil) + uploader = subject.retrieve_uploader + + expect(uploader.upload).to eq(subject) + expect(uploader.path).to include('attachment') + expect(uploader.file).not_to be_nil + end + end + + context 'when an upload does not belong to a note' do + it 'does not mount it as attachment' do + appearance = create(:appearance) + + subject = build(:upload, :with_file, :attachment_upload, model: appearance, mount_point: nil) + uploader = subject.retrieve_uploader + + expect(uploader.upload).to eq(subject) + expect(uploader.path).not_to include('attachment') + expect(uploader.file).not_to be_nil + end + end + end end describe '#needs_checksum?' do |