summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-29 18:17:11 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-31 12:55:45 -0300
commit325de662ce79ea75348c303e05b2f0045835193e (patch)
tree4eea5b7686033f4a133ebf20785f305736001744 /spec/helpers
parent7649497fb5d81a1597e76f52a8bc0582e98489cd (diff)
downloadgitlab-ce-325de662ce79ea75348c303e05b2f0045835193e.tar.gz
Don't create groups for unallowed users when importing projects
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/import_helper_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb
index 3391234e9f5..187b891b927 100644
--- a/spec/helpers/import_helper_spec.rb
+++ b/spec/helpers/import_helper_spec.rb
@@ -1,6 +1,30 @@
require 'rails_helper'
describe ImportHelper do
+ describe '#import_project_target' do
+ let(:user) { create(:user) }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
+ context 'when current user can create namespaces' do
+ it 'returns project namespace' do
+ user.update_attribute(:can_create_group, true)
+
+ expect(helper.import_project_target('asd', 'vim')).to eq 'asd/vim'
+ end
+ end
+
+ context 'when current user can not create namespaces' do
+ it "takes the current user's namespace" do
+ user.update_attribute(:can_create_group, false)
+
+ expect(helper.import_project_target('asd', 'vim')).to eq "#{user.namespace_path}/vim"
+ end
+ end
+ end
+
describe '#github_project_link' do
context 'when provider does not specify a custom URL' do
it 'uses default GitHub URL' do