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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-04 06:14:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-04 06:14:51 +0300
commit73270622cc7b3e40c019f3b1aad7ebfa2c224ba0 (patch)
treeeaee70f3b108d254bf16a6847d4e8724f1fbd18c /spec
parent54efc4fee638a0f47372961b24c0efa477e5b01a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb12
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb15
-rw-r--r--spec/rubocop/cop/gitlab/license_available_usage_spec.rb34
4 files changed, 34 insertions, 43 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb
index 44ccb1eeae1..bf146791659 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb
@@ -12,13 +12,10 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules do
end
let(:step) { described_class.new(pipeline, command) }
- let(:ff_always_set_pipeline_failure_reason) { true }
describe '#perform!' do
context 'when pipeline has been skipped by workflow configuration' do
before do
- stub_feature_flags(always_set_pipeline_failure_reason: ff_always_set_pipeline_failure_reason)
-
allow(step).to receive(:workflow_rules_result)
.and_return(
double(pass?: false, variables: {})
@@ -47,15 +44,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules do
expect(pipeline).to be_failed
expect(pipeline).to be_filtered_by_workflow_rules
end
-
- context 'when always_set_pipeline_failure_reason is disabled' do
- let(:ff_always_set_pipeline_failure_reason) { false }
-
- it 'does not set the failure reason', :aggregate_failures do
- expect(pipeline).not_to be_failed
- expect(pipeline.failure_reason).to be_blank
- end
- end
end
context 'when pipeline has not been skipped by workflow configuration' do
diff --git a/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb
index 123428cde0e..5956137a725 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb
@@ -52,22 +52,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Helpers, feature_category: :continuo
expect(pipeline.status).to eq 'failed'
expect(pipeline.failure_reason).to eq drop_reason.to_s
end
-
- context 'when feature flag always_set_pipeline_failure_reason is false' do
- before do
- stub_feature_flags(always_set_pipeline_failure_reason: false)
- end
-
- specify do
- subject.error(message, config_error: config_error, drop_reason: drop_reason)
-
- if command.save_incompleted
- expect(pipeline.failure_reason).to eq drop_reason.to_s
- else
- expect(pipeline.failure_reason).not_to be_present
- end
- end
- end
end
context 'when the error includes malicious HTML' do
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
index 476b1be35a9..22ff367c746 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
@@ -34,15 +34,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Populate, feature_category: :continu
{ rspec: { script: 'rspec' } }
end
- let(:ff_always_set_pipeline_failure_reason) { true }
-
def run_chain
dependencies.map(&:perform!)
step.perform!
end
before do
- stub_feature_flags(always_set_pipeline_failure_reason: ff_always_set_pipeline_failure_reason)
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
@@ -113,18 +110,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Populate, feature_category: :continu
expect(pipeline).to be_failed
expect(pipeline).to be_filtered_by_rules
end
-
- context 'when ff always_set_pipeline_failure_reason is disabled' do
- let(:ff_always_set_pipeline_failure_reason) { false }
-
- it 'sets the failure reason without persisting the pipeline', :aggregate_failures do
- run_chain
-
- expect(pipeline).not_to be_persisted
- expect(pipeline).not_to be_failed
- expect(pipeline).not_to be_filtered_by_rules
- end
- end
end
describe 'pipeline protect' do
diff --git a/spec/rubocop/cop/gitlab/license_available_usage_spec.rb b/spec/rubocop/cop/gitlab/license_available_usage_spec.rb
new file mode 100644
index 00000000000..230224e8e53
--- /dev/null
+++ b/spec/rubocop/cop/gitlab/license_available_usage_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'rubocop_spec_helper'
+require 'rspec-parameterized'
+require_relative '../../../../rubocop/cop/gitlab/license_available_usage'
+
+RSpec.describe RuboCop::Cop::Gitlab::LicenseAvailableUsage, feature_category: :shared do
+ let(:msg) { described_class::MSG }
+
+ describe 'uses license check' do
+ it 'registers an offense' do
+ expect_offense(<<~SOURCE)
+ License.feature_available?(:elastic_search) && super
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid License.feature_available? usage in ApplicationSetting due to possible cyclical dependency issue. For more information see: https://gitlab.com/gitlab-org/gitlab/-/issues/423237
+ SOURCE
+ end
+ end
+
+ describe 'no license check' do
+ let(:source) do
+ <<~RUBY
+ class C
+ def check_without_license_usage?
+ test?(:feature)
+ end
+ end
+ RUBY
+ end
+
+ it 'does not register an offense' do
+ expect_no_offenses(source)
+ end
+ end
+end