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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /spec/services/projects
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'spec/services/projects')
-rw-r--r--spec/services/projects/create_service_spec.rb30
-rw-r--r--spec/services/projects/destroy_service_spec.rb61
-rw-r--r--spec/services/projects/download_service_spec.rb4
-rw-r--r--spec/services/projects/participants_service_spec.rb16
-rw-r--r--spec/services/projects/update_service_spec.rb2
5 files changed, 88 insertions, 25 deletions
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index 59db0b47a3c..8a737e4df56 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -1030,17 +1030,17 @@ RSpec.describe Projects::CreateService, '#execute', feature_category: :groups_an
end
before do
- group.update_shared_runners_setting!(shared_runners_setting)
+ group.update!(shared_runners_enabled: shared_runners_enabled,
+ allow_descendants_override_disabled_shared_runners: allow_to_override)
user.refresh_authorized_projects # Ensure cache is warm
end
context 'default value based on parent group setting' do
- where(:shared_runners_setting, :desired_config_for_new_project, :expected_result_for_project) do
- Namespace::SR_ENABLED | nil | true
- Namespace::SR_DISABLED_WITH_OVERRIDE | nil | false
- Namespace::SR_DISABLED_AND_OVERRIDABLE | nil | false
- Namespace::SR_DISABLED_AND_UNOVERRIDABLE | nil | false
+ where(:shared_runners_enabled, :allow_to_override, :desired_config_for_new_project, :expected_result_for_project) do
+ true | false | nil | true
+ false | true | nil | false
+ false | false | nil | false
end
with_them do
@@ -1057,14 +1057,12 @@ RSpec.describe Projects::CreateService, '#execute', feature_category: :groups_an
end
context 'parent group is present and allows desired config' do
- where(:shared_runners_setting, :desired_config_for_new_project, :expected_result_for_project) do
- Namespace::SR_ENABLED | true | true
- Namespace::SR_ENABLED | false | false
- Namespace::SR_DISABLED_WITH_OVERRIDE | false | false
- Namespace::SR_DISABLED_WITH_OVERRIDE | true | true
- Namespace::SR_DISABLED_AND_OVERRIDABLE | false | false
- Namespace::SR_DISABLED_AND_OVERRIDABLE | true | true
- Namespace::SR_DISABLED_AND_UNOVERRIDABLE | false | false
+ where(:shared_runners_enabled, :allow_to_override, :desired_config_for_new_project, :expected_result_for_project) do
+ true | false | true | true
+ true | false | false | false
+ false | true | false | false
+ false | true | true | true
+ false | false | false | false
end
with_them do
@@ -1080,8 +1078,8 @@ RSpec.describe Projects::CreateService, '#execute', feature_category: :groups_an
end
context 'parent group is present and disallows desired config' do
- where(:shared_runners_setting, :desired_config_for_new_project) do
- Namespace::SR_DISABLED_AND_UNOVERRIDABLE | true
+ where(:shared_runners_enabled, :allow_to_override, :desired_config_for_new_project) do
+ false | false | true
end
with_them do
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index 7aa6980fb24..ccf58964c71 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -456,14 +456,63 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
end
context 'repository removal' do
- # 1. Project repository
- # 2. Wiki repository
- it 'removal of existing repos' do
- expect_next_instances_of(Repositories::DestroyService, 2) do |instance|
- expect(instance).to receive(:execute).and_return(status: :success)
+ describe '.trash_project_repositories!' do
+ let(:trash_project_repositories!) { described_class.new(project, user, {}).send(:trash_project_repositories!) }
+
+ # Destroys 3 repositories:
+ # 1. Project repository
+ # 2. Wiki repository
+ # 3. Design repository
+
+ it 'Repositories::DestroyService is called for existing repos' do
+ expect_next_instances_of(Repositories::DestroyService, 3) do |instance|
+ expect(instance).to receive(:execute).and_return(status: :success)
+ end
+
+ trash_project_repositories!
end
- described_class.new(project, user, {}).execute
+ context 'when the removal has errors' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:mock_error) { instance_double(Repositories::DestroyService, execute: { message: 'foo', status: :error }) }
+ let(:project_repository) { project.repository }
+ let(:wiki_repository) { project.wiki.repository }
+ let(:design_repository) { project.design_repository }
+
+ where(:repo, :message) do
+ ref(:project_repository) | 'Failed to remove project repository. Please try again or contact administrator.'
+ ref(:wiki_repository) | 'Failed to remove wiki repository. Please try again or contact administrator.'
+ ref(:design_repository) | 'Failed to remove design repository. Please try again or contact administrator.'
+ end
+
+ with_them do
+ before do
+ allow(Repositories::DestroyService).to receive(:new).with(anything).and_call_original
+ allow(Repositories::DestroyService).to receive(:new).with(repo).and_return(mock_error)
+ end
+
+ it 'raises correct error' do
+ expect { trash_project_repositories! }.to raise_error(Projects::DestroyService::DestroyError, message)
+ end
+ end
+ end
+ end
+
+ it 'removes project repository' do
+ expect { destroy_project(project, user, {}) }.to change { project.repository.exists? }.from(true).to(false)
+ end
+
+ it 'removes wiki repository' do
+ project.create_wiki unless project.wiki.repository.exists?
+
+ expect { destroy_project(project, user, {}) }.to change { project.wiki.repository.exists? }.from(true).to(false)
+ end
+
+ it 'removes design repository' do
+ project.design_repository.create_if_not_exists
+
+ expect { destroy_project(project, user, {}) }.to change { project.design_repository.exists? }.from(true).to(false)
end
end
diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb
index e062ee04bf4..a0b14a36106 100644
--- a/spec/services/projects/download_service_spec.rb
+++ b/spec/services/projects/download_service_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Projects::DownloadService, feature_category: :groups_and_projects
@project = create(:project, creator_id: @user.id, namespace: @user.namespace)
end
- context 'for a URL that is not on whitelist' do
+ context 'for a URL that is not on allowlist' do
before do
url = 'https://code.jquery.com/jquery-2.1.4.min.js'
@link_to_file = download_file(@project, url)
@@ -18,7 +18,7 @@ RSpec.describe Projects::DownloadService, feature_category: :groups_and_projects
it { expect(@link_to_file).to eq(nil) }
end
- context 'for URLs that are on the whitelist' do
+ context 'for URLs that are on the allowlist' do
before do
# `ssrf_filter` resolves the hostname. See https://github.com/carrierwaveuploader/carrierwave/commit/91714adda998bc9e8decf5b1f5d260d808761304
stub_request(:get, %r{http://[\d.]+/rails_sample.jpg}).to_return(body: File.read(Rails.root + 'spec/fixtures/rails_sample.jpg'))
diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb
index 2f090577805..04c43dff2dc 100644
--- a/spec/services/projects/participants_service_spec.rb
+++ b/spec/services/projects/participants_service_spec.rb
@@ -10,12 +10,18 @@ RSpec.describe Projects::ParticipantsService, feature_category: :groups_and_proj
before_all do
project.add_developer(user)
+
+ stub_feature_flags(disable_all_mention: false)
end
def run_service
described_class.new(project, user).execute(noteable)
end
+ it 'includes `All Project and Group Members`' do
+ expect(run_service).to include(a_hash_including({ username: "all", name: "All Project and Group Members" }))
+ end
+
context 'N+1 checks' do
before do
run_service # warmup, runs table cache queries and create queries
@@ -99,6 +105,16 @@ RSpec.describe Projects::ParticipantsService, feature_category: :groups_and_proj
end
end
end
+
+ context 'when `disable_all_mention` FF is enabled' do
+ before do
+ stub_feature_flags(disable_all_mention: true)
+ end
+
+ it 'does not include `All Project and Group Members`' do
+ expect(run_service).not_to include(a_hash_including({ username: "all", name: "All Project and Group Members" }))
+ end
+ end
end
describe '#project_members' do
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index badbc8b628e..bfcd2be6ce4 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -690,7 +690,7 @@ RSpec.describe Projects::UpdateService, feature_category: :groups_and_projects d
attributes_for(
:prometheus_integration,
project: project,
- properties: { api_url: nil, manual_configuration: "1" }
+ properties: { api_url: 'invalid-url', manual_configuration: "1" }
)
end