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/models/ci/processable_spec.rb')
-rw-r--r--spec/models/ci/processable_spec.rb64
1 files changed, 61 insertions, 3 deletions
diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb
index e1c449e18ac..c6af7609778 100644
--- a/spec/models/ci/processable_spec.rb
+++ b/spec/models/ci/processable_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::Processable, feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
- let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be_with_refind(:pipeline) { create(:ci_pipeline, project: project) }
describe 'delegations' do
subject { described_class.new }
@@ -31,7 +31,8 @@ RSpec.describe Ci::Processable, feature_category: :continuous_integration do
let_it_be_with_refind(:processable) do
create(:ci_bridge, :success,
- pipeline: pipeline, downstream: downstream_project, description: 'a trigger job', stage_id: stage.id)
+ pipeline: pipeline, downstream: downstream_project, description: 'a trigger job', stage_id: stage.id,
+ environment: 'production')
end
let(:clone_accessors) { ::Ci::Bridge.clone_accessors }
@@ -77,7 +78,7 @@ RSpec.describe Ci::Processable, feature_category: :continuous_integration do
job_artifacts_requirements job_artifacts_coverage_fuzzing
job_artifacts_requirements_v2
job_artifacts_api_fuzzing terraform_state_versions job_artifacts_cyclonedx
- job_annotations].freeze
+ job_annotations job_artifacts_annotations].freeze
end
let(:ignore_accessors) do
@@ -503,4 +504,61 @@ RSpec.describe Ci::Processable, feature_category: :continuous_integration do
end
end
end
+
+ describe '.manual_actions' do
+ shared_examples_for 'manual actions for a job' do
+ let!(:manual_but_created) { create(factory_type, :manual, status: :created, pipeline: pipeline) }
+ let!(:manual_but_succeeded) { create(factory_type, :manual, status: :success, pipeline: pipeline) }
+ let!(:manual_action) { create(factory_type, :manual, pipeline: pipeline) }
+
+ subject { described_class.manual_actions }
+
+ it { is_expected.to include(manual_action) }
+ it { is_expected.to include(manual_but_succeeded) }
+ it { is_expected.not_to include(manual_but_created) }
+ end
+
+ it_behaves_like 'manual actions for a job' do
+ let(:factory_type) { :ci_build }
+ end
+
+ it_behaves_like 'manual actions for a job' do
+ let(:factory_type) { :ci_bridge }
+ end
+ end
+
+ describe '#other_manual_actions' do
+ let_it_be(:user) { create(:user) }
+
+ before_all do
+ project.add_developer(user)
+ end
+
+ shared_examples_for 'other manual actions for a job' do
+ let(:job) { create(factory_type, :manual, pipeline: pipeline, project: project) }
+ let!(:other_job) { create(factory_type, :manual, pipeline: pipeline, project: project, name: 'other action') }
+
+ subject { job.other_manual_actions }
+
+ it 'returns other actions' do
+ is_expected.to contain_exactly(other_job)
+ end
+
+ context 'when job is retried' do
+ let!(:new_job) { Ci::RetryJobService.new(project, user).execute(job)[:job] }
+
+ it 'does not return any of them' do
+ is_expected.not_to include(job, new_job)
+ end
+ end
+ end
+
+ it_behaves_like 'other manual actions for a job' do
+ let(:factory_type) { :ci_build }
+ end
+
+ it_behaves_like 'other manual actions for a job' do
+ let(:factory_type) { :ci_bridge }
+ end
+ end
end