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-02-01 21:11:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-01 21:11:40 +0300
commit3bfb19d99e3508b2a42c49d09e5a3236d2ce3a29 (patch)
treedc3a6a664e81caaa99530260ad56821479a8a939 /spec/services
parent18d5458781b21dee4dbb8854c72c064e9bd808ed (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/google_cloud/fetch_google_ip_list_service_spec.rb2
-rw-r--r--spec/services/merge_requests/after_create_service_spec.rb13
-rw-r--r--spec/services/security/ci_configuration/sast_create_service_spec.rb48
3 files changed, 54 insertions, 9 deletions
diff --git a/spec/services/google_cloud/fetch_google_ip_list_service_spec.rb b/spec/services/google_cloud/fetch_google_ip_list_service_spec.rb
index ef77958fa60..e5f06824b9f 100644
--- a/spec/services/google_cloud/fetch_google_ip_list_service_spec.rb
+++ b/spec/services/google_cloud/fetch_google_ip_list_service_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe GoogleCloud::FetchGoogleIpListService, :use_clean_rails_memory_store_caching,
-:clean_gitlab_redis_rate_limiting, feature_category: :continuous_integration do
+:clean_gitlab_redis_rate_limiting, feature_category: :build_artifacts do
include StubRequests
let(:google_cloud_ips) { File.read(Rails.root.join('spec/fixtures/cdn/google_cloud.json')) }
diff --git a/spec/services/merge_requests/after_create_service_spec.rb b/spec/services/merge_requests/after_create_service_spec.rb
index f477b2166d9..f2823b1f0c7 100644
--- a/spec/services/merge_requests/after_create_service_spec.rb
+++ b/spec/services/merge_requests/after_create_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe MergeRequests::AfterCreateService do
+RSpec.describe MergeRequests::AfterCreateService, feature_category: :code_review_workflow do
let_it_be(:merge_request) { create(:merge_request) }
subject(:after_create_service) do
@@ -126,6 +126,17 @@ RSpec.describe MergeRequests::AfterCreateService do
end
end
+ it 'updates the prepared_at' do
+ # Need to reset the `prepared_at` since it can be already set in preceding tests.
+ merge_request.update!(prepared_at: nil)
+
+ freeze_time do
+ expect { execute_service }.to change { merge_request.prepared_at }
+ .from(nil)
+ .to(Time.current)
+ end
+ end
+
it 'increments the usage data counter of create event' do
counter = Gitlab::UsageDataCounters::MergeRequestCounter
diff --git a/spec/services/security/ci_configuration/sast_create_service_spec.rb b/spec/services/security/ci_configuration/sast_create_service_spec.rb
index 1e6dc367146..39c32567f3c 100644
--- a/spec/services/security/ci_configuration/sast_create_service_spec.rb
+++ b/spec/services/security/ci_configuration/sast_create_service_spec.rb
@@ -24,7 +24,45 @@ RSpec.describe Security::CiConfiguration::SastCreateService, :snowplow, feature_
include_examples 'services security ci configuration create service'
- context "when committing to the default branch", :aggregate_failures do
+ RSpec.shared_examples_for 'commits directly to the default branch' do
+ it 'commits directly to the default branch' do
+ expect(project).to receive(:default_branch).twice.and_return('master')
+
+ expect(result.status).to eq(:success)
+ expect(result.payload[:success_path]).to match(/#{Gitlab::Routing.url_helpers.project_new_merge_request_url(project, {})}(.*)description(.*)source_branch/)
+ expect(result.payload[:branch]).to eq('master')
+ end
+ end
+
+ context 'when the repository is empty' do
+ let_it_be(:project) { create(:project_empty_repo) }
+
+ context 'when initialize_with_sast is false' do
+ before do
+ project.add_developer(user)
+ end
+
+ let(:params) { { initialize_with_sast: false } }
+
+ it 'raises an error' do
+ expect { result }.to raise_error(Gitlab::Graphql::Errors::MutationError)
+ end
+ end
+
+ context 'when initialize_with_sast is true' do
+ let(:params) { { initialize_with_sast: true } }
+
+ subject(:result) { described_class.new(project, user, params, commit_on_default: true).execute }
+
+ before do
+ project.add_maintainer(user)
+ end
+
+ it_behaves_like 'commits directly to the default branch'
+ end
+ end
+
+ context 'when committing to the default branch', :aggregate_failures do
subject(:result) { described_class.new(project, user, params, commit_on_default: true).execute }
let(:params) { {} }
@@ -33,17 +71,13 @@ RSpec.describe Security::CiConfiguration::SastCreateService, :snowplow, feature_
project.add_developer(user)
end
- it "doesn't try to remove that branch on raised exceptions" do
+ it 'does not try to remove that branch on raised exceptions' do
expect(Files::MultiService).to receive(:new).and_raise(StandardError, '_exception_')
expect(project.repository).not_to receive(:rm_branch)
expect { result }.to raise_error(StandardError, '_exception_')
end
- it "commits directly to the default branch" do
- expect(result.status).to eq(:success)
- expect(result.payload[:success_path]).to match(/#{Gitlab::Routing.url_helpers.project_new_merge_request_url(project, {})}(.*)description(.*)source_branch/)
- expect(result.payload[:branch]).to eq('master')
- end
+ it_behaves_like 'commits directly to the default branch'
end
end