summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/tree_controller_spec.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2015-12-08 12:35:54 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2015-12-08 12:35:54 +0100
commit6d2be0212c444c6a3d25ae6a3c75822fa1c8614f (patch)
tree66c12a4f7863ded395300a56de689b5cb669e84b /spec/controllers/projects/tree_controller_spec.rb
parentad37f58ebd97fee3c06a531e4067c8adb4c9ecc7 (diff)
parentf5430e48b42227f1c1874ca27c6907f0f704be28 (diff)
downloadgitlab-ce-6d2be0212c444c6a3d25ae6a3c75822fa1c8614f.tar.gz
Merge branch 'master' into sync-all-repos
Diffstat (limited to 'spec/controllers/projects/tree_controller_spec.rb')
-rw-r--r--spec/controllers/projects/tree_controller_spec.rb36
1 files changed, 36 insertions, 0 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