Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/groups')
-rw-r--r--spec/services/groups/create_service_spec.rb20
-rw-r--r--spec/services/groups/deploy_tokens/revoke_service_spec.rb28
-rw-r--r--spec/services/groups/destroy_service_spec.rb13
3 files changed, 40 insertions, 21 deletions
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb
index 7ec523a1f2b..819569d6e67 100644
--- a/spec/services/groups/create_service_spec.rb
+++ b/spec/services/groups/create_service_spec.rb
@@ -85,14 +85,6 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with before_commit callback' do
it_behaves_like 'has sync-ed traversal_ids'
end
-
- context 'with after_create callback' do
- before do
- stub_feature_flags(sync_traversal_ids_before_commit: false)
- end
-
- it_behaves_like 'has sync-ed traversal_ids'
- end
end
context 'when user can not create a group' do
@@ -119,17 +111,7 @@ RSpec.describe Groups::CreateService, '#execute' do
expect { subject }.not_to change(OnboardingProgress, :count).from(0)
end
- context 'with before_commit callback' do
- it_behaves_like 'has sync-ed traversal_ids'
- end
-
- context 'with after_create callback' do
- before do
- stub_feature_flags(sync_traversal_ids_before_commit: false)
- end
-
- it_behaves_like 'has sync-ed traversal_ids'
- end
+ it_behaves_like 'has sync-ed traversal_ids'
end
context 'as guest' do
diff --git a/spec/services/groups/deploy_tokens/revoke_service_spec.rb b/spec/services/groups/deploy_tokens/revoke_service_spec.rb
new file mode 100644
index 00000000000..fcf11bbb8e6
--- /dev/null
+++ b/spec/services/groups/deploy_tokens/revoke_service_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Groups::DeployTokens::RevokeService do
+ let_it_be(:entity) { create(:group) }
+ let_it_be(:deploy_token) { create(:deploy_token, :group, groups: [entity]) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:deploy_token_params) { { id: deploy_token.id } }
+
+ describe '#execute' do
+ subject { described_class.new(entity, user, deploy_token_params).execute }
+
+ it "revokes a group deploy token" do
+ expect(deploy_token.revoked).to eq(false)
+
+ expect { subject }.to change { deploy_token.reload.revoked }.to eq(true)
+ end
+
+ context 'invalid token id' do
+ let(:deploy_token_params) { { token_id: non_existing_record_id } }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+ end
+end
diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb
index 5135be8fff5..628943e40ff 100644
--- a/spec/services/groups/destroy_service_spec.rb
+++ b/spec/services/groups/destroy_service_spec.rb
@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe Groups::DestroyService do
- include DatabaseConnectionHelpers
-
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
@@ -112,6 +110,17 @@ RSpec.describe Groups::DestroyService do
end
end
+ context 'when group owner is blocked' do
+ before do
+ user.block!
+ end
+
+ it 'returns a more descriptive error message' do
+ expect { destroy_group(group, user, false) }
+ .to raise_error(Groups::DestroyService::DestroyError, "You can't delete this group because you're blocked.")
+ end
+ end
+
describe 'repository removal' do
before do
destroy_group(group, user, false)