Commit a089f8a3 authored by Sushil khanchi's avatar Sushil khanchi Committed by Markus Koller

Designs: return an error if uploading designs with duplicate names

parent ac31fd07
......@@ -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