diff options
Diffstat (limited to 'spec/serializers/group_child_entity_spec.rb')
-rw-r--r-- | spec/serializers/group_child_entity_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/serializers/group_child_entity_spec.rb b/spec/serializers/group_child_entity_spec.rb index 59340181075..469189c0768 100644 --- a/spec/serializers/group_child_entity_spec.rb +++ b/spec/serializers/group_child_entity_spec.rb @@ -6,7 +6,8 @@ RSpec.describe GroupChildEntity do include ExternalAuthorizationServiceHelpers include Gitlab::Routing.url_helpers - let(:user) { create(:user) } + let_it_be(:user) { create(:user) } + let(:request) { double('request') } let(:entity) { described_class.new(object, request: request) } @@ -103,6 +104,22 @@ RSpec.describe GroupChildEntity do expect(json[:can_leave]).to be_truthy end + it 'allows an owner to delete the group' do + expect(json[:can_remove]).to be_truthy + end + + it 'allows admin to delete the group', :enable_admin_mode do + allow(request).to receive(:current_user).and_return(create(:admin)) + + expect(json[:can_remove]).to be_truthy + end + + it 'disallows a maintainer to delete the group' do + object.add_maintainer(user) + + expect(json[:can_remove]).to be_falsy + end + it 'has the correct edit path' do expect(json[:edit_path]).to eq(edit_group_path(object)) end |