summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-29 18:51:29 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-29 18:51:29 +0000
commit23fc1f666cf62b21485b216bbd86a10637a98d6c (patch)
tree7e3fef4337ea45ec79421db93648e11a7d76e288 /spec/services
parent714f70a38df10e678bffde6e6081a97e31d8317c (diff)
parent283e868ef523185b0ee314b9e2164599780d888b (diff)
downloadgitlab-ce-23fc1f666cf62b21485b216bbd86a10637a98d6c.tar.gz
Merge branch 'dz-nested-group-misc' into 'master'
Miscellaneous improvements to the nested groups feature See merge request !8308
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/groups/create_service_spec.rb31
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb
index 71a0b8e2a12..14717a7455d 100644
--- a/spec/services/groups/create_service_spec.rb
+++ b/spec/services/groups/create_service_spec.rb
@@ -1,11 +1,12 @@
require 'spec_helper'
-describe Groups::CreateService, services: true do
- let!(:user) { create(:user) }
+describe Groups::CreateService, '#execute', services: true do
+ let!(:user) { create(:user) }
let!(:group_params) { { path: "group_path", visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
- describe "execute" do
- let!(:service) { described_class.new(user, group_params ) }
+ describe 'visibility level restrictions' do
+ let!(:service) { described_class.new(user, group_params) }
+
subject { service.execute }
context "create groups without restricted visibility level" do
@@ -14,7 +15,29 @@ describe Groups::CreateService, services: true do
context "cannot create group with restricted visibility level" do
before { allow_any_instance_of(ApplicationSetting).to receive(:restricted_visibility_levels).and_return([Gitlab::VisibilityLevel::PUBLIC]) }
+
it { is_expected.not_to be_persisted }
end
end
+
+ describe 'creating subgroup' do
+ let!(:group) { create(:group) }
+ let!(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) }
+
+ subject { service.execute }
+
+ context 'as group owner' do
+ before { group.add_owner(user) }
+
+ it { is_expected.to be_persisted }
+ end
+
+ context 'as guest' do
+ it 'does not save group and returns an error' do
+ is_expected.not_to be_persisted
+ expect(subject.errors[:parent_id].first).to eq('manage access required to create subgroup')
+ expect(subject.parent_id).to be_nil
+ end
+ end
+ end
end