diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-07 21:08:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-07 21:08:08 +0300 |
commit | 59f37a99433dbdc3093e06f0f57beff171bae5d4 (patch) | |
tree | 61f7e6c66fd79fda1ec46b223225012241eff3e7 /spec | |
parent | fa4473a48706d074217f4ffc8d183cf630af1833 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
26 files changed, 399 insertions, 56 deletions
diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb index 111bfb24c7e..773a416dcb4 100644 --- a/spec/controllers/confirmations_controller_spec.rb +++ b/spec/controllers/confirmations_controller_spec.rb @@ -10,17 +10,27 @@ RSpec.describe ConfirmationsController do end describe '#show' do + let_it_be_with_reload(:user) { create(:user, :unconfirmed) } + let(:confirmation_token) { user.confirmation_token } + render_views def perform_request get :show, params: { confirmation_token: confirmation_token } end - context 'user is already confirmed' do - let_it_be_with_reload(:user) { create(:user, :unconfirmed) } + context 'when signup info is required' do + before do + allow(controller).to receive(:current_user) { user } + user.set_role_required! + end - let(:confirmation_token) { user.confirmation_token } + it 'does not redirect' do + expect(perform_request).not_to redirect_to(users_sign_up_welcome_path) + end + end + context 'user is already confirmed' do before do user.confirm end @@ -57,10 +67,6 @@ RSpec.describe ConfirmationsController do end context 'user accesses the link after the expiry of confirmation token has passed' do - let_it_be_with_reload(:user) { create(:user, :unconfirmed) } - - let(:confirmation_token) { user.confirmation_token } - before do allow(Devise).to receive(:confirm_within).and_return(1.day) end @@ -133,6 +139,17 @@ RSpec.describe ConfirmationsController do stub_feature_flags(identity_verification: false) end + context 'when signup info is required' do + before do + allow(controller).to receive(:current_user) { user } + user.set_role_required! + end + + it 'does not redirect' do + expect(perform_request).not_to redirect_to(users_sign_up_welcome_path) + end + end + context 'when reCAPTCHA is disabled' do before do stub_application_setting(recaptcha_enabled: false) diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 0b468854322..306888b9ab8 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -139,7 +139,7 @@ RSpec.describe 'Dashboard Projects' do end describe 'with a pipeline', :clean_gitlab_redis_shared_state do - let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch) } + let!(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch) } before do # Since the cache isn't updated when a new pipeline is created diff --git a/spec/frontend/editor/schema/ci/ci_schema_spec.js b/spec/frontend/editor/schema/ci/ci_schema_spec.js index 3d843e8fb81..b2c9118ddcf 100644 --- a/spec/frontend/editor/schema/ci/ci_schema_spec.js +++ b/spec/frontend/editor/schema/ci/ci_schema_spec.js @@ -35,7 +35,6 @@ import JobWhenYaml from './yaml_tests/positive_tests/job_when.yml'; // YAML NEGATIVE TEST import ArtifactsNegativeYaml from './yaml_tests/negative_tests/artifacts.yml'; -import CacheNegativeYaml from './yaml_tests/negative_tests/cache.yml'; import IncludeNegativeYaml from './yaml_tests/negative_tests/include.yml'; import RulesNegativeYaml from './yaml_tests/negative_tests/rules.yml'; import VariablesNegativeYaml from './yaml_tests/negative_tests/variables.yml'; @@ -62,6 +61,16 @@ import ProjectPathTriggerProjectLeadSlashYaml from './yaml_tests/negative_tests/ import ProjectPathTriggerProjectNoSlashYaml from './yaml_tests/negative_tests/project_path/trigger/project/no_slash.yml'; import ProjectPathTriggerProjectTailSlashYaml from './yaml_tests/negative_tests/project_path/trigger/project/tailing_slash.yml'; +import CacheKeyFilesNotArray from './yaml_tests/negative_tests/cache/key_files_not_an_array.yml'; +import CacheKeyPrefixArray from './yaml_tests/negative_tests/cache/key_prefix_array.yml'; +import CacheKeyWithDot from './yaml_tests/negative_tests/cache/key_with_dot.yml'; +import CacheKeyWithMultipleDots from './yaml_tests/negative_tests/cache/key_with_multiple_dots.yml'; +import CacheKeyWithSlash from './yaml_tests/negative_tests/cache/key_with_slash.yml'; +import CachePathsNotAnArray from './yaml_tests/negative_tests/cache/paths_not_an_array.yml'; +import CacheUntrackedString from './yaml_tests/negative_tests/cache/untracked_string.yml'; +import CacheWhenInteger from './yaml_tests/negative_tests/cache/when_integer.yml'; +import CacheWhenNotReservedKeyword from './yaml_tests/negative_tests/cache/when_not_reserved_keyword.yml'; + const ajv = new Ajv({ strictTypes: false, strictTuples: false, @@ -116,7 +125,15 @@ describe('negative tests', () => { // YAML ArtifactsNegativeYaml, - CacheNegativeYaml, + CacheKeyFilesNotArray, + CacheKeyPrefixArray, + CacheKeyWithDot, + CacheKeyWithMultipleDots, + CacheKeyWithSlash, + CachePathsNotAnArray, + CacheUntrackedString, + CacheWhenInteger, + CacheWhenNotReservedKeyword, IncludeNegativeYaml, JobWhenNegativeYaml, RulesNegativeYaml, diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml deleted file mode 100644 index 04020c06753..00000000000 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml +++ /dev/null @@ -1,13 +0,0 @@ -stages: - - prepare - -# invalid cache:when values -when no integer: - stage: prepare - cache: - when: 0 - -when must be a reserved word: - stage: prepare - cache: - when: 'never' diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_files_not_an_array.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_files_not_an_array.yml new file mode 100644 index 00000000000..64b927a9940 --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_files_not_an_array.yml @@ -0,0 +1,8 @@ +cache-key-files-not-an-array: + script: echo "This job uses a cache." + cache: + key: + files: package.json + paths: + - vendor/ruby + - node_modules diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_prefix_array.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_prefix_array.yml new file mode 100644 index 00000000000..9024dfe6441 --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_prefix_array.yml @@ -0,0 +1,10 @@ +cache-key-prefix-array: + script: echo "This job uses a cache." + cache: + key: + files: + - Gemfile.lock + prefix: + - binaries-cache-$CI_JOB_NAME + paths: + - binaries/ diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_dot.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_dot.yml new file mode 100644 index 00000000000..7d21e5f4111 --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_dot.yml @@ -0,0 +1,6 @@ +cache-key-with-.: + script: echo "This job uses a cache." + cache: + key: . + paths: + - binaries/ diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_multiple_dots.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_multiple_dots.yml new file mode 100644 index 00000000000..1256be628d1 --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_multiple_dots.yml @@ -0,0 +1,7 @@ +cache-key-with-multiple-.: + stage: test + script: echo "This job uses a cache." + cache: + key: .. + paths: + - binaries/ diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_slash.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_slash.yml new file mode 100644 index 00000000000..ea6c0345bd4 --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/key_with_slash.yml @@ -0,0 +1,6 @@ +cache-key-with-/: + script: echo "This job uses a cache." + cache: + key: binaries-ca/che + paths: + - binaries/ diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/paths_not_an_array.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/paths_not_an_array.yml new file mode 100644 index 00000000000..26cc8d1935e --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/paths_not_an_array.yml @@ -0,0 +1,5 @@ +cache-path-not-an-array: + script: echo "This job uses a cache." + cache: + key: binaries-cache + paths: binaries/*.apk diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/untracked_string.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/untracked_string.yml new file mode 100644 index 00000000000..ed21e87f009 --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/untracked_string.yml @@ -0,0 +1,4 @@ +cache-untracked-string: + script: echo "This job uses a cache." + cache: + untracked: 'true' diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/when_integer.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/when_integer.yml new file mode 100644 index 00000000000..5420bd9d0dd --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/when_integer.yml @@ -0,0 +1,4 @@ +when_integer: + script: echo "This job uses a cache." + cache: + when: 0 diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/when_not_reserved_keyword.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/when_not_reserved_keyword.yml new file mode 100644 index 00000000000..2a6e204a6db --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache/when_not_reserved_keyword.yml @@ -0,0 +1,4 @@ +when_not_reserved_keyword: + script: echo "This job uses a cache." + cache: + when: 'never' diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml index d83e14fdc6a..75918cd2a1b 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml @@ -1,24 +1,124 @@ -stages: - - prepare - # valid cache:when values job1: - stage: prepare script: - echo 'running job' cache: when: 'on_success' job2: - stage: prepare script: - echo 'running job' cache: when: 'on_failure' job3: - stage: prepare script: - echo 'running job' cache: when: 'always' + +# valid cache:paths +cache-paths: + script: echo "This job uses a cache." + cache: + key: binaries-cache + paths: + - binaries/*.apk + - .config + +# valid cache:key +cache-key-string: + script: echo "This job uses a cache." + cache: + key: random-string + paths: + - binaries/ + +cache-key-string-with-dots: + script: echo "This job uses a cache." + cache: + key: random-..string + paths: + - binaries/ + +cache-key-string-beginning-with-dot: + script: echo "This job uses a cache." + cache: + key: .random-string + paths: + - binaries/ + +cache-key-string-ending-with-dot: + script: echo "This job uses a cache." + cache: + key: random-string. + paths: + - binaries/ + +cache-key-predefined-variable: + script: echo "This job uses a cache." + cache: + key: $CI_COMMIT_REF_SLUG + paths: + - binaries/ + +cache-key-combination: + script: echo "This job uses a cache." + cache: + key: binaries-cache-$CI_COMMIT_REF_SLUG + paths: + - binaries/ + +# valid cache:key:files +cache-key-files: + script: echo "This job uses a cache." + cache: + key: + files: + - Gemfile.lock + - package.json + paths: + - vendor/ruby + - node_modules + +# valide cache:key:prefix +cache-key-prefix-string: + script: echo "This job uses a cache." + cache: + key: + files: + - Gemfile.lock + prefix: random-string + paths: + - binaries/ + +cache-key-prefix-predefined-variable: + script: echo "This job uses a cache." + cache: + key: + files: + - Gemfile.lock + prefix: $CI_JOB_NAME + paths: + - binaries/ + +cache-key-prefix-combination: + script: echo "This job uses a cache." + cache: + key: + files: + - Gemfile.lock + prefix: binaries-cache-$CI_JOB_NAME + paths: + - binaries/ + +# valid cache:untracked +cache-untracked-true: + script: test + cache: + untracked: true + +cache-untracked-false: + script: test + cache: + untracked: false diff --git a/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js b/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js index b17239384a7..814a1e68142 100644 --- a/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js @@ -28,7 +28,7 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { propsData: { isCollapsible: false, loadingText: 'Loading widget', - widgetName: 'MyWidget', + widgetName: 'WidgetTest', value: { collapsed: null, expanded: null, @@ -94,6 +94,14 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { await nextTick(); expect(wrapper.text()).toContain('Loading'); }); + + it('validates widget name', () => { + expect(() => { + createComponent({ + propsData: { fetchCollapsedData: jest.fn(), widgetName: 'InvalidWidgetName' }, + }); + }).toThrow(); + }); }); describe('fetch', () => { diff --git a/spec/graphql/types/projects/branch_rule_type_spec.rb b/spec/graphql/types/projects/branch_rule_type_spec.rb index 119ecf8a097..41923ebb6a9 100644 --- a/spec/graphql/types/projects/branch_rule_type_spec.rb +++ b/spec/graphql/types/projects/branch_rule_type_spec.rb @@ -17,7 +17,7 @@ RSpec.describe GitlabSchema.types['BranchRule'] do ] end - specify { is_expected.to require_graphql_authorizations(:read_protected_branch) } + it { is_expected.to require_graphql_authorizations(:read_protected_branch) } - specify { is_expected.to have_graphql_fields(fields).at_least } + it { is_expected.to have_graphql_fields(fields).at_least } end diff --git a/spec/lib/gitlab/error_tracking_spec.rb b/spec/lib/gitlab/error_tracking_spec.rb index fd859ae40fb..4900547e9e9 100644 --- a/spec/lib/gitlab/error_tracking_spec.rb +++ b/spec/lib/gitlab/error_tracking_spec.rb @@ -369,6 +369,25 @@ RSpec.describe Gitlab::ErrorTracking do end end + context 'when exception is excluded' do + before do + stub_const('SubclassRetryError', Class.new(Gitlab::SidekiqMiddleware::RetryError)) + end + + ['Gitlab::SidekiqMiddleware::RetryError', 'SubclassRetryError'].each do |ex| + let(:exception) { ex.constantize.new } + + it "does not report #{ex} exception to Sentry" do + expect(Gitlab::ErrorTracking::Logger).to receive(:error) + + track_exception + + expect(Raven.client.transport.events).to eq([]) + expect(Sentry.get_current_client.transport.events).to eq([]) + end + end + end + context 'when processing invalid URI exceptions' do let(:invalid_uri) { 'http://foo:bar' } let(:raven_exception_values) { raven_event['exception']['values'] } diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index c11927150e4..53baad9f99a 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -367,6 +367,7 @@ protected_branches: - push_access_levels - unprotect_access_levels - approval_project_rules +- external_status_checks - required_code_owners_sections protected_tags: - project diff --git a/spec/lib/gitlab/request_forgery_protection_spec.rb b/spec/lib/gitlab/request_forgery_protection_spec.rb index a7b777cf4f2..fe93fe9c828 100644 --- a/spec/lib/gitlab/request_forgery_protection_spec.rb +++ b/spec/lib/gitlab/request_forgery_protection_spec.rb @@ -13,6 +13,18 @@ RSpec.describe Gitlab::RequestForgeryProtection, :allow_forgery_protection do } end + it 'logs to /dev/null' do + logger = described_class::Controller.new.logger + + # Taken from ActiveSupport.logger_outputs_to? + # There is no equivalent /dev/null stream like STDOUT, so + # we need to extract the path. + logdev = logger.instance_variable_get(:@logdev) + logger_source = logdev.dev + + expect(logger_source.path).to eq(File::NULL) + end + describe '.call' do context 'when the request method is GET' do before do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 6a5162a85ae..7efaa9ebdd5 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -166,7 +166,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do it do pipeline.status = from_status.to_s - if from_status != to_status + if from_status != to_status || success_to_success? expect(pipeline.set_status(to_status.to_s)) .to eq(true) else @@ -174,6 +174,12 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do .to eq(false), "loopback transitions are not allowed" end end + + private + + def success_to_success? + from_status == :success && to_status == :success + end end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 928f9d6d057..88b13a1c0ea 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -2406,23 +2406,6 @@ RSpec.describe Group do end end - describe '.groups_including_descendants_by' do - let_it_be(:parent_group1) { create(:group) } - let_it_be(:parent_group2) { create(:group) } - let_it_be(:extra_group) { create(:group) } - let_it_be(:child_group1) { create(:group, parent: parent_group1) } - let_it_be(:child_group2) { create(:group, parent: parent_group1) } - let_it_be(:child_group3) { create(:group, parent: parent_group2) } - - subject { described_class.groups_including_descendants_by([parent_group2.id, parent_group1.id]) } - - shared_examples 'returns the expected groups for a group and its descendants' do - specify { is_expected.to contain_exactly(parent_group1, parent_group2, child_group1, child_group2, child_group3) } - end - - it_behaves_like 'returns the expected groups for a group and its descendants' - end - describe '.preset_root_ancestor_for' do let_it_be(:rootgroup, reload: true) { create(:group) } let_it_be(:subgroup, reload: true) { create(:group, parent: rootgroup) } diff --git a/spec/serializers/remote_mirror_entity_spec.rb b/spec/serializers/remote_mirror_entity_spec.rb index 4cbf87e4d67..c6290e15995 100644 --- a/spec/serializers/remote_mirror_entity_spec.rb +++ b/spec/serializers/remote_mirror_entity_spec.rb @@ -3,8 +3,7 @@ require 'spec_helper' RSpec.describe RemoteMirrorEntity do - let(:project) { create(:project, :repository, :remote_mirror, url: "https://test:password@gitlab.com") } - let(:remote_mirror) { project.remote_mirrors.first } + let(:remote_mirror) { build_stubbed(:remote_mirror, url: "https://test:password@gitlab.com") } let(:entity) { described_class.new(remote_mirror) } subject { entity.as_json } diff --git a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb index 9a37736967e..1fbefc1fa22 100644 --- a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb +++ b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do check_expectation(test_file.dig('init', 'expect'), "init") test_file['transitions'].each_with_index do |transition, idx| - event_on_jobs(transition['event'], transition['jobs']) + process_events(transition) Sidekiq::Worker.drain_all # ensure that all async jobs are executed check_expectation(transition['expect'], "transition:#{idx}") end @@ -48,6 +48,14 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do } end + def process_events(transition) + if transition['jobs'] + event_on_jobs(transition['event'], transition['jobs']) + else + event_on_pipeline(transition['event']) + end + end + def event_on_jobs(event, job_names) statuses = pipeline.latest_statuses.by_name(job_names).to_a expect(statuses.count).to eq(job_names.count) # ensure that we have the same counts @@ -63,6 +71,14 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do end end end + + def event_on_pipeline(event) + if event == 'retry' + pipeline.retry_failed(user) + else + pipeline.public_send("#{event}!") + end + end end end diff --git a/spec/services/ci/pipeline_processing/test_cases/stage_one_test_succeeds_one_manual_test_fails_and_retry_manual_build.yml b/spec/services/ci/pipeline_processing/test_cases/stage_one_test_succeeds_one_manual_test_fails_and_retry_manual_build.yml new file mode 100644 index 00000000000..a50fe56f8d4 --- /dev/null +++ b/spec/services/ci/pipeline_processing/test_cases/stage_one_test_succeeds_one_manual_test_fails_and_retry_manual_build.yml @@ -0,0 +1,54 @@ +config: + test1: + script: exit 0 + + test2: + when: manual + script: exit 1 + +init: + expect: + pipeline: pending + stages: + test: pending + jobs: + test1: pending + test2: manual + +transitions: + - event: success + jobs: [test1] + expect: + pipeline: success + stages: + test: success + jobs: + test1: success + test2: manual + - event: play + jobs: [test2] + expect: + pipeline: running + stages: + test: running + jobs: + test1: success + test2: pending + - event: drop + jobs: [test2] + expect: + pipeline: success + stages: + test: success + jobs: + test1: success + test2: failed + - event: retry + jobs: [test2] + expect: + pipeline: running + stages: + test: running + jobs: + test1: success + test2: pending diff --git a/spec/services/ci/pipeline_processing/test_cases/stage_one_test_succeeds_one_manual_test_fails_and_retry_pipeline.yml b/spec/services/ci/pipeline_processing/test_cases/stage_one_test_succeeds_one_manual_test_fails_and_retry_pipeline.yml new file mode 100644 index 00000000000..a6112a95a12 --- /dev/null +++ b/spec/services/ci/pipeline_processing/test_cases/stage_one_test_succeeds_one_manual_test_fails_and_retry_pipeline.yml @@ -0,0 +1,53 @@ +config: + test1: + script: exit 0 + + test2: + when: manual + script: exit 1 + +init: + expect: + pipeline: pending + stages: + test: pending + jobs: + test1: pending + test2: manual + +transitions: + - event: success + jobs: [test1] + expect: + pipeline: success + stages: + test: success + jobs: + test1: success + test2: manual + - event: play + jobs: [test2] + expect: + pipeline: running + stages: + test: running + jobs: + test1: success + test2: pending + - event: drop + jobs: [test2] + expect: + pipeline: success + stages: + test: success + jobs: + test1: success + test2: failed + - event: retry + expect: + pipeline: success + stages: + test: success + jobs: + test1: success + test2: manual diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb index 96437290ae3..77345096537 100644 --- a/spec/services/ci/retry_pipeline_service_spec.rb +++ b/spec/services/ci/retry_pipeline_service_spec.rb @@ -5,14 +5,16 @@ require 'spec_helper' RSpec.describe Ci::RetryPipelineService, '#execute' do include ProjectForksHelper - let(:user) { create(:user) } - let(:project) { create(:project) } + let_it_be_with_refind(:user) { create(:user) } + let_it_be_with_refind(:project) { create(:project) } + let(:pipeline) { create(:ci_pipeline, project: project) } - let(:service) { described_class.new(project, user) } let(:build_stage) { create(:ci_stage, name: 'build', position: 0, pipeline: pipeline) } let(:test_stage) { create(:ci_stage, name: 'test', position: 1, pipeline: pipeline) } let(:deploy_stage) { create(:ci_stage, name: 'deploy', position: 2, pipeline: pipeline) } + subject(:service) { described_class.new(project, user) } + context 'when user has full ability to modify pipeline' do before do project.add_developer(user) @@ -272,6 +274,21 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do expect(pipeline.reload).to be_running end end + + context 'when there is a failed manual action' do + before do + create_build('rspec', :success, build_stage) + create_build('manual-rspec', :failed, build_stage, when: :manual, allow_failure: true) + end + + it 'processes the manual action' do + service.execute(pipeline) + + expect(build('rspec')).to be_success + expect(build('manual-rspec')).to be_manual + expect(pipeline.reload).to be_success + end + end end it 'closes all todos about failed jobs for pipeline' do |