diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-10-15 11:47:36 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-10-15 11:47:36 +0200 |
commit | c993481d991333fe0750080eec98fd2e9eeda8d5 (patch) | |
tree | 7d1fdd7926f8542b7fbf7add052004dbfd48b206 /spec/controllers/projects | |
parent | 83f04853e9a749c3397ee7683a78b986e1070904 (diff) | |
parent | 123669a55107514798ba531ba3a744b3ec8503ee (diff) | |
download | gitlab-ce-c993481d991333fe0750080eec98fd2e9eeda8d5.tar.gz |
Merge branch 'master' into git-archive-golanggit-archive-golang
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/tree_controller_spec.rb | 36 | ||||
-rw-r--r-- | spec/controllers/projects/uploads_controller_spec.rb | 4 |
2 files changed, 38 insertions, 2 deletions
diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 53915856357..a474574c6e5 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -88,4 +88,40 @@ describe Projects::TreeController do end end end + + describe '#create_dir' do + render_views + + before do + post(:create_dir, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: 'master', + dir_name: path, + new_branch: target_branch, + commit_message: 'Test commit message') + end + + context 'successful creation' do + let(:path) { 'files/new_dir'} + let(:target_branch) { 'master-test'} + + it 'redirects to the new directory' do + expect(subject). + to redirect_to("/#{project.path_with_namespace}/blob/#{target_branch}/#{path}") + expect(flash[:notice]).to eq('The directory has been successfully created') + end + end + + context 'unsuccessful creation' do + let(:path) { 'README.md' } + let(:target_branch) { 'master'} + + it 'does not allow overwriting of existing files' do + expect(subject). + to redirect_to("/#{project.path_with_namespace}/blob/master") + expect(flash[:alert]).to eq('Directory already exists as a file') + end + end + end end diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb index f51abfedae5..93c4494c660 100644 --- a/spec/controllers/projects/uploads_controller_spec.rb +++ b/spec/controllers/projects/uploads_controller_spec.rb @@ -33,7 +33,7 @@ describe Projects::UploadsController do it 'returns a content with original filename, new link, and correct type.' do expect(response.body).to match '\"alt\":\"rails_sample\"' - expect(response.body).to match "\"url\":\"http://localhost/#{project.path_with_namespace}/uploads" + expect(response.body).to match "\"url\":\"/uploads" expect(response.body).to match '\"is_image\":true' end end @@ -49,7 +49,7 @@ describe Projects::UploadsController do it 'returns a content with original filename, new link, and correct type.' do expect(response.body).to match '\"alt\":\"doc_sample.txt\"' - expect(response.body).to match "\"url\":\"http://localhost/#{project.path_with_namespace}/uploads" + expect(response.body).to match "\"url\":\"/uploads" expect(response.body).to match '\"is_image\":false' end end |