Allow creation of files and directories with spaces in web UI
This commit is contained in:
parent
81dba76b9d
commit
d1e0b1b3a8
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Allow creation of files and directories with spaces through Web UI
|
||||||
|
merge_request: 12608
|
||||||
|
author:
|
|
@ -93,7 +93,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
step 'I fill the new file name with an illegal name' do
|
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
|
end
|
||||||
|
|
||||||
step 'I fill the new file name with a new directory' do
|
step 'I fill the new file name with a new directory' do
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_name_regex
|
def file_name_regex
|
||||||
@file_name_regex ||= /\A[[[:alnum:]]_\-\.\@\+]*\z/.freeze
|
@file_name_regex ||= /\A[^\/\0]*\z/.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_name_regex_message
|
def file_name_regex_message
|
||||||
|
|
|
@ -25,6 +25,16 @@ describe Gitlab::Git::Index, seed_helper: true do
|
||||||
expect(entry).not_to be_nil
|
expect(entry).not_to be_nil
|
||||||
expect(repository.lookup(entry[:oid]).content).to eq(options[:content])
|
expect(repository.lookup(entry[:oid]).content).to eq(options[:content])
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'when a file at that path exists' do
|
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
|
expect(entry).not_to be_nil
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'when a file at that path exists' do
|
context 'when a file at that path exists' do
|
||||||
|
|
|
@ -347,6 +347,16 @@ describe Repository, models: true do
|
||||||
expect(blob.data).to eq('Changelog!')
|
expect(blob.data).to eq('Changelog!')
|
||||||
end
|
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
|
it 'respects the autocrlf setting' do
|
||||||
repository.create_file(user, 'hello.txt', "Hello,\r\nWorld",
|
repository.create_file(user, 'hello.txt', "Hello,\r\nWorld",
|
||||||
message: 'Add hello world',
|
message: 'Add hello world',
|
||||||
|
|
Loading…
Reference in New Issue