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/helpers/ci')
-rw-r--r--spec/helpers/ci/builds_helper_spec.rb14
-rw-r--r--spec/helpers/ci/pipeline_editor_helper_spec.rb2
-rw-r--r--spec/helpers/ci/pipelines_helper_spec.rb52
-rw-r--r--spec/helpers/ci/runners_helper_spec.rb14
-rw-r--r--spec/helpers/ci/secure_files_helper_spec.rb76
5 files changed, 141 insertions, 17 deletions
diff --git a/spec/helpers/ci/builds_helper_spec.rb b/spec/helpers/ci/builds_helper_spec.rb
index 143d96cf632..ea3b5aac4ea 100644
--- a/spec/helpers/ci/builds_helper_spec.rb
+++ b/spec/helpers/ci/builds_helper_spec.rb
@@ -97,6 +97,20 @@ RSpec.describe Ci::BuildsHelper do
end
end
+ describe '#prepare_failed_jobs_summary_data' do
+ let(:failed_build) { create(:ci_build, :failed, :trace_live) }
+
+ subject { helper.prepare_failed_jobs_summary_data([failed_build]) }
+
+ it 'returns array of failed jobs with id, failure and failure summary' do
+ expect(subject).to eq([{
+ id: failed_build.id,
+ failure: failed_build.present.callout_failure_message,
+ failure_summary: helper.build_summary(failed_build)
+ }].to_json)
+ end
+ end
+
def assign_project
build(:project).tap do |project|
assign(:project, project)
diff --git a/spec/helpers/ci/pipeline_editor_helper_spec.rb b/spec/helpers/ci/pipeline_editor_helper_spec.rb
index 12456deb538..429d4c7941a 100644
--- a/spec/helpers/ci/pipeline_editor_helper_spec.rb
+++ b/spec/helpers/ci/pipeline_editor_helper_spec.rb
@@ -45,6 +45,7 @@ RSpec.describe Ci::PipelineEditorHelper do
"default-branch" => project.default_branch_or_main,
"empty-state-illustration-path" => 'foo',
"initial-branch-name" => nil,
+ "includes-help-page-path" => help_page_path('ci/yaml/includes'),
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'check-cicd-syntax'),
"lint-unavailable-help-page-path" => help_page_path('ci/pipeline_editor/index', anchor: 'configuration-validation-currently-not-available-message'),
"needs-help-page-path" => help_page_path('ci/yaml/index', anchor: 'needs'),
@@ -72,6 +73,7 @@ RSpec.describe Ci::PipelineEditorHelper do
"default-branch" => project.default_branch_or_main,
"empty-state-illustration-path" => 'foo',
"initial-branch-name" => nil,
+ "includes-help-page-path" => help_page_path('ci/yaml/includes'),
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'check-cicd-syntax'),
"lint-unavailable-help-page-path" => help_page_path('ci/pipeline_editor/index', anchor: 'configuration-validation-currently-not-available-message'),
"needs-help-page-path" => help_page_path('ci/yaml/index', anchor: 'needs'),
diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb
index c473e1e4ab6..19946afb1a4 100644
--- a/spec/helpers/ci/pipelines_helper_spec.rb
+++ b/spec/helpers/ci/pipelines_helper_spec.rb
@@ -152,18 +152,18 @@ RSpec.describe Ci::PipelinesHelper do
end
end
- describe 'the `registration_token` attribute' do
- subject { data[:registration_token] }
+ describe 'when the project is eligible for the `ios_specific_templates` experiment' do
+ let_it_be(:project) { create(:project, :auto_devops_disabled, shared_runners_enabled: false) }
+ let_it_be(:user) { create(:user) }
- describe 'when the project is eligible for the `ios_specific_templates` experiment' do
- let_it_be(:project) { create(:project, :auto_devops_disabled) }
- let_it_be(:user) { create(:user) }
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ project.add_developer(user)
+ create(:project_setting, project: project, target_platforms: %w(ios))
+ end
- before do
- allow(helper).to receive(:current_user).and_return(user)
- project.add_developer(user)
- create(:project_setting, project: project, target_platforms: %w(ios))
- end
+ describe 'the `registration_token` attribute' do
+ subject { data[:registration_token] }
context 'when the `ios_specific_templates` experiment variant is control' do
before do
@@ -191,6 +191,38 @@ RSpec.describe Ci::PipelinesHelper do
end
end
end
+
+ describe 'the `ios_runners_available` attribute' do
+ before do
+ allow(Gitlab).to receive(:com?).and_return(true)
+ end
+
+ subject { data[:ios_runners_available] }
+
+ context 'when the `ios_specific_templates` experiment variant is control' do
+ before do
+ stub_experiments(ios_specific_templates: :control)
+ end
+
+ it { is_expected.to be_nil }
+ end
+
+ context 'when the `ios_specific_templates` experiment variant is candidate' do
+ before do
+ stub_experiments(ios_specific_templates: :candidate)
+ end
+
+ context 'when shared runners are not enabled' do
+ it { is_expected.to eq('false') }
+ end
+
+ context 'when shared runners are enabled' do
+ let_it_be(:project) { create(:project, :auto_devops_disabled, shared_runners_enabled: true) }
+
+ it { is_expected.to eq('true') }
+ end
+ end
+ end
end
end
end
diff --git a/spec/helpers/ci/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb
index 0046d481282..cf62579338f 100644
--- a/spec/helpers/ci/runners_helper_spec.rb
+++ b/spec/helpers/ci/runners_helper_spec.rb
@@ -99,17 +99,17 @@ RSpec.describe Ci::RunnersHelper do
let(:runner_constants) do
{
- runner_enabled: Namespace::SR_ENABLED,
- runner_disabled: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
- runner_allow_override: Namespace::SR_DISABLED_WITH_OVERRIDE
+ runner_enabled_value: Namespace::SR_ENABLED,
+ runner_disabled_value: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
+ runner_allow_override_value: Namespace::SR_DISABLED_WITH_OVERRIDE
}
end
it 'returns group data for top level group' do
result = {
update_path: "/api/v4/groups/#{parent.id}",
- shared_runners_availability: Namespace::SR_ENABLED,
- parent_shared_runners_availability: nil
+ shared_runners_setting: Namespace::SR_ENABLED,
+ parent_shared_runners_setting: nil
}.merge(runner_constants)
expect(helper.group_shared_runners_settings_data(parent)).to eq result
@@ -118,8 +118,8 @@ RSpec.describe Ci::RunnersHelper do
it 'returns group data for child group' do
result = {
update_path: "/api/v4/groups/#{group.id}",
- shared_runners_availability: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
- parent_shared_runners_availability: Namespace::SR_ENABLED
+ shared_runners_setting: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
+ parent_shared_runners_setting: Namespace::SR_ENABLED
}.merge(runner_constants)
expect(helper.group_shared_runners_settings_data(group)).to eq result
diff --git a/spec/helpers/ci/secure_files_helper_spec.rb b/spec/helpers/ci/secure_files_helper_spec.rb
new file mode 100644
index 00000000000..02da44f56b2
--- /dev/null
+++ b/spec/helpers/ci/secure_files_helper_spec.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::SecureFilesHelper do
+ let_it_be(:maintainer) { create(:user) }
+ let_it_be(:developer) { create(:user) }
+ let_it_be(:guest) { create(:user) }
+ let_it_be(:anonymous) { create(:user) }
+ let_it_be(:unconfirmed) { create(:user, :unconfirmed) }
+ let_it_be(:project) { create(:project, creator_id: maintainer.id) }
+
+ before_all do
+ project.add_maintainer(maintainer)
+ project.add_developer(developer)
+ project.add_guest(guest)
+ end
+
+ subject { helper.show_secure_files_setting(project, user) }
+
+ describe '#show_secure_files_setting' do
+ context 'when the :ci_secure_files feature flag is enabled' do
+ before do
+ stub_feature_flags(ci_secure_files: true)
+ end
+
+ context 'authenticated user with admin permissions' do
+ let(:user) { maintainer }
+
+ it { is_expected.to be true }
+ end
+
+ context 'authenticated user with read permissions' do
+ let(:user) { developer }
+
+ it { is_expected.to be true }
+ end
+
+ context 'authenticated user with guest permissions' do
+ let(:user) { guest }
+
+ it { is_expected.to be false }
+ end
+
+ context 'authenticated user with no permissions' do
+ let(:user) { anonymous }
+
+ it { is_expected.to be false }
+ end
+
+ context 'unconfirmed user' do
+ let(:user) { unconfirmed }
+
+ it { is_expected.to be false }
+ end
+
+ context 'unauthenticated user' do
+ let(:user) { nil }
+
+ it { is_expected.to be false }
+ end
+ end
+
+ context 'when the :ci_secure_files feature flag is disabled' do
+ before do
+ stub_feature_flags(ci_secure_files: false)
+ end
+
+ context 'authenticated user with admin permissions' do
+ let(:user) { maintainer }
+
+ it { is_expected.to be false }
+ end
+ end
+ end
+end