diff options
author | George Andrinopoulos <geoandri@gmail.com> | 2017-03-24 18:19:50 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-24 18:19:50 +0000 |
commit | 2f9d50b72fedf09900289e6a0bcf59433d0c05f5 (patch) | |
tree | 8d998283e4f503f24f50cad49104e11ff607b864 /spec | |
parent | c0ce9d0157a8bf4b4e2558ea81987491f17ce6ac (diff) | |
download | gitlab-ce-2f9d50b72fedf09900289e6a0bcf59433d0c05f5.tar.gz |
Resolve "Gitlab administrator cannot create projects in every group"
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/namespaces_helper_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb new file mode 100644 index 00000000000..e5143a0263d --- /dev/null +++ b/spec/helpers/namespaces_helper_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe NamespacesHelper, type: :helper do + let!(:admin) { create(:admin) } + let!(:admin_group) { create(:group, :private) } + let!(:user) { create(:user) } + let!(:user_group) { create(:group, :private) } + + before do + admin_group.add_owner(admin) + user_group.add_owner(user) + end + + describe '#namespaces_options' do + it 'returns groups without being a member for admin' do + allow(helper).to receive(:current_user).and_return(admin) + + options = helper.namespaces_options(user_group.id, display_path: true, extra_group: user_group.id) + + expect(options).to include(admin_group.name) + expect(options).to include(user_group.name) + end + + it 'returns only allowed namespaces for user' do + allow(helper).to receive(:current_user).and_return(user) + + options = helper.namespaces_options + + expect(options).not_to include(admin_group.name) + expect(options).to include(user_group.name) + end + end +end |