Commit 83e6f705 authored by Markus Koller's avatar Markus Koller

Merge branch 'khanchi-designs-patch' into 'master'

Designs: return an error if uploading designs with duplicate names

See merge request gitlab-org/gitlab!42514
parents 79682a70 a089f8a3
......@@ -16,6 +16,7 @@ module DesignManagement
def execute
return error("Not allowed!") unless can_create_designs?
return error("Only #{MAX_FILES} files are allowed simultaneously") if files.size > MAX_FILES
return error("Duplicate filenames are not allowed!") if files.map(&:original_filename).uniq.length != files.length
uploaded_designs, version = upload_designs!
skipped_designs = designs - uploaded_designs
......
---
title: 'Designs: return an error if uploading designs with duplicate names'
merge_request: 42514
author: Sushil Khanchi
type: fixed
......@@ -271,6 +271,14 @@ RSpec.describe DesignManagement::SaveDesignsService do
expect(response[:message]).to match(/only \d+ files are allowed simultaneously/i)
end
end
context 'when uploading duplicate files' do
let(:files) { [rails_sample, dk_png, rails_sample] }
it 'returns the correct error' do
expect(response[:message]).to match('Duplicate filenames are not allowed!')
end
end
end
context 'when the user is not allowed to upload designs' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment