Skip to content
Snippets Groups Projects
Commit d1e0b1b3 authored by Tiago Botelho's avatar Tiago Botelho
Browse files

Allow creation of files and directories with spaces in web UI

parent 81dba76b
No related branches found
No related tags found
No related merge requests found
---
title: Allow creation of files and directories with spaces through Web UI
merge_request: 12608
author:
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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',
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment