diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-07-05 19:01:38 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-07-05 21:10:14 +0300 |
commit | 1207d451ed934f3ce2d8c02130a8e6b2cac88a70 (patch) | |
tree | 35f501038ecc6cde3927666d4011d0fb03f9b771 /spec | |
parent | d1e0b1b3a8404f3a7b54db09c46fb614ca3fcb93 (diff) |
Removes file_name_regex from Gitlab::Regex
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/files/creating_a_file_spec.rb | 5 | ||||
-rw-r--r-- | spec/lib/gitlab/git/index_spec.rb | 19 | ||||
-rw-r--r-- | spec/lib/gitlab/regex_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 9 |
4 files changed, 5 insertions, 34 deletions
diff --git a/spec/features/projects/files/creating_a_file_spec.rb b/spec/features/projects/files/creating_a_file_spec.rb index 2a1cc01fe68..f67cb46eaaa 100644 --- a/spec/features/projects/files/creating_a_file_spec.rb +++ b/spec/features/projects/files/creating_a_file_spec.rb @@ -30,11 +30,6 @@ feature 'User wants to create a file', feature: true do expect(page).to have_content 'The file has been successfully created' end - scenario 'file name contains invalid characters' do - submit_new_file(file_name: '\\') - expect(page).to have_content 'Path can contain only' - end - scenario 'file name contains directory traversal' do submit_new_file(file_name: '../README.md') expect(page).to have_content 'Path cannot include directory traversal' diff --git a/spec/lib/gitlab/git/index_spec.rb b/spec/lib/gitlab/git/index_spec.rb index 8d63f81e4fd..21b71654251 100644 --- a/spec/lib/gitlab/git/index_spec.rb +++ b/spec/lib/gitlab/git/index_spec.rb @@ -25,16 +25,6 @@ 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 @@ -91,15 +81,6 @@ 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 diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 979f4fefcb6..51e2c3c38c6 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -14,12 +14,6 @@ describe Gitlab::Regex, lib: true do it { is_expected.not_to match('?gitlab') } end - describe '.file_name_regex' do - subject { described_class.file_name_regex } - - it { is_expected.to match('foo@bar') } - end - describe '.environment_slug_regex' do subject { described_class.environment_name_regex } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 80b363355da..af305e9b234 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -347,14 +347,15 @@ describe Repository, models: true do expect(blob.data).to eq('Changelog!') end - it 'creates new file with spaces in between successfully' do + it 'creates new file and dir when file_path has a forward slash' do expect do - repository.create_file(user, 'NEW FILE', 'File!', - message: 'Create NEW FILE', + repository.create_file(user, 'new_dir/new_file.txt', 'File!', + message: 'Create new_file with new_dir', branch_name: 'master') end.to change { repository.commits('master').count }.by(1) - expect(repository.blob_at('master', 'NEW FILE').data).to eq('File!') + expect(repository.tree('master', 'new_dir').path).to eq('new_dir') + expect(repository.blob_at('master', 'new_dir/new_file.txt').data).to eq('File!') end it 'respects the autocrlf setting' do |