diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 21:07:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 21:07:17 +0300 |
commit | 3fbd6ba74ee268ad739599ae14dcf5c9b6acfc2c (patch) | |
tree | eea3db86df012fd59b4db8c4ec132e494bdac8fb /spec/services | |
parent | d41edc2e93480db35e48ad770ebe95075fbca871 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/groups/transfer_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/import/github_service_spec.rb | 56 | ||||
-rw-r--r-- | spec/services/members/destroy_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/notification_service_spec.rb | 2 |
5 files changed, 55 insertions, 9 deletions
diff --git a/spec/services/groups/transfer_service_spec.rb b/spec/services/groups/transfer_service_spec.rb index 8939382c023..10399bed655 100644 --- a/spec/services/groups/transfer_service_spec.rb +++ b/spec/services/groups/transfer_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Groups::TransferService, :sidekiq_inline do +RSpec.describe Groups::TransferService, :sidekiq_inline, feature_category: :subgroups do shared_examples 'project namespace path is in sync with project path' do it 'keeps project and project namespace attributes in sync' do projects_with_project_namespace.each do |project| diff --git a/spec/services/import/github_service_spec.rb b/spec/services/import/github_service_spec.rb index d1b372c5e87..293e247c140 100644 --- a/spec/services/import/github_service_spec.rb +++ b/spec/services/import/github_service_spec.rb @@ -7,22 +7,19 @@ RSpec.describe Import::GithubService do let_it_be(:token) { 'complex-token' } let_it_be(:access_params) { { github_access_token: 'github-complex-token' } } let(:settings) { instance_double(Gitlab::GithubImport::Settings) } + let(:user_namespace_path) { user.namespace_path } let(:optional_stages) { nil } let(:params) do { repo_id: 123, new_name: 'new_repo', - target_namespace: 'root', + target_namespace: user_namespace_path, optional_stages: optional_stages } end subject(:github_importer) { described_class.new(client, user, params) } - before do - allow(subject).to receive(:authorized?).and_return(true) - end - shared_examples 'handles errors' do |klass| let(:client) { klass.new(token) } let(:project_double) { instance_double(Project, persisted?: true) } @@ -74,6 +71,7 @@ RSpec.describe Import::GithubService do let(:repository_double) { { name: 'repository', size: 99 } } before do + allow(subject).to receive(:authorized?).and_return(true) expect(client).to receive(:repository).and_return(repository_double) allow_next_instance_of(Gitlab::LegacyGithubImport::ProjectCreator) do |creator| @@ -215,6 +213,38 @@ RSpec.describe Import::GithubService do end end end + + context 'when target_namespace is blank' do + before do + params[:target_namespace] = '' + end + + it 'raises an exception' do + expect { subject.execute(access_params, :github) }.to raise_error(ArgumentError, 'Target namespace is required') + end + end + + context 'when namespace to import repository into does not exist' do + before do + params[:target_namespace] = 'unknown_path' + end + + it 'returns an error' do + expect(github_importer.execute(access_params, :github)).to include(not_existed_namespace_error) + end + end + + context 'when user has no permissions to import repository into the specified namespace' do + let_it_be(:group) { create(:group) } + + before do + params[:target_namespace] = group.full_path + end + + it 'returns an error' do + expect(github_importer.execute(access_params, :github)).to include(taken_namespace_error) + end + end end context 'when remove_legacy_github_client feature flag is enabled' do @@ -248,4 +278,20 @@ RSpec.describe Import::GithubService do message: "Invalid URL: #{url}" } end + + def not_existed_namespace_error + { + status: :error, + http_status: :unprocessable_entity, + message: 'Namespace or group to import repository into does not exist.' + } + end + + def taken_namespace_error + { + status: :error, + http_status: :unprocessable_entity, + message: 'This namespace has already been taken. Choose a different one.' + } + end end diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index 2af47635dfa..d8a8d5881bf 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Members::DestroyService do +RSpec.describe Members::DestroyService, feature_category: :subgroups do let(:current_user) { create(:user) } let(:member_user) { create(:user) } let(:group) { create(:group, :public) } diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 0427debb4d1..0814942b6b7 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe MergeRequests::RefreshService do +RSpec.describe MergeRequests::RefreshService, feature_category: :code_review_workflow do include ProjectForksHelper include UserHelpers diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index a18a7d0c64a..1ad9234c939 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe NotificationService, :mailer do +RSpec.describe NotificationService, :mailer, feature_category: :team_planning do include EmailSpec::Matchers include ExternalAuthorizationServiceHelpers include NotificationHelpers |