Allow creation of files and directories with spaces in web UI

This commit is contained in:
Tiago Botelho 2017-07-03 13:55:43 +01:00
parent 81dba76b9d
commit d1e0b1b3a8
5 changed files with 35 additions and 2 deletions

View file

@ -0,0 +1,4 @@
---
title: Allow creation of files and directories with spaces through Web UI
merge_request: 12608
author:

View file

@ -93,7 +93,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
end
step 'I fill the new file name with an illegal name' do
fill_in :file_name, with: 'Spaces Not Allowed'
fill_in :file_name, with: 'Filename/Slash'
end
step 'I fill the new file name with a new directory' do

View file

@ -20,7 +20,7 @@ module Gitlab
end
def file_name_regex
@file_name_regex ||= /\A[[[:alnum:]]_\-\.\@\+]*\z/.freeze
@file_name_regex ||= /\A[^\/\0]*\z/.freeze
end
def file_name_regex_message

View file

@ -25,6 +25,16 @@ describe Gitlab::Git::Index, seed_helper: true do
expect(entry).not_to be_nil
expect(repository.lookup(entry[:oid]).content).to eq(options[:content])
end
it 'creates the file if file_path has spaces in between words' do
options[:file_path] = 'new file.txt'
index.create(options)
entry = index.get(options[:file_path])
expect(entry).not_to be_nil
expect(repository.lookup(entry[:oid]).content).to eq(options[:content])
end
end
context 'when a file at that path exists' do
@ -81,6 +91,15 @@ describe Gitlab::Git::Index, seed_helper: true do
expect(entry).not_to be_nil
end
it 'creates the dir if it has spaces in between words' do
options[:file_path] = 'new dir'
index.create_dir(options)
entry = index.get(options[:file_path] + '/.gitkeep')
expect(entry).not_to be_nil
end
end
context 'when a file at that path exists' do

View file

@ -347,6 +347,16 @@ describe Repository, models: true do
expect(blob.data).to eq('Changelog!')
end
it 'creates new file with spaces in between successfully' do
expect do
repository.create_file(user, 'NEW FILE', 'File!',
message: 'Create NEW FILE',
branch_name: 'master')
end.to change { repository.commits('master').count }.by(1)
expect(repository.blob_at('master', 'NEW FILE').data).to eq('File!')
end
it 'respects the autocrlf setting' do
repository.create_file(user, 'hello.txt', "Hello,\r\nWorld",
message: 'Add hello world',