From f62dc67d262792829bdcaef779b3915e9cc93a4f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 25 Feb 2019 20:05:26 +0900 Subject: [PATCH] Add suffix for merge request event Fix ok Add spec Fix ok Fix Add changelog Fix Add memoization a fix --- app/models/ci/build.rb | 2 +- app/models/ci/pipeline.rb | 20 +++++----- app/models/ci/pipeline_enums.rb | 2 +- app/models/concerns/has_ref.rb | 2 +- app/presenters/ci/build_runner_presenter.rb | 2 +- app/serializers/pipeline_entity.rb | 4 +- app/services/merge_requests/base_service.rb | 2 +- app/views/projects/pipelines/_info.html.haml | 2 +- ...rge-request-between-pipeline-and-build.yml | 5 +++ lib/gitlab/ci/build/policy/refs.rb | 8 +++- spec/factories/merge_requests.rb | 2 +- .../user_sees_merge_request_pipelines_spec.rb | 8 ++-- .../projects/pipelines/pipeline_spec.rb | 2 +- .../gitlab/ci/build/policy/changes_spec.rb | 2 +- spec/lib/gitlab/ci/build/policy/refs_spec.rb | 14 +++++++ .../gitlab/ci/pipeline/chain/build_spec.rb | 4 +- .../ci/pipeline/chain/validate/config_spec.rb | 2 +- spec/models/ci/build_spec.rb | 2 +- spec/models/ci/pipeline_spec.rb | 40 +++++++++---------- spec/models/merge_request_spec.rb | 6 +-- spec/requests/api/runner_spec.rb | 2 +- .../ci/create_pipeline_service_spec.rb | 4 +- .../merge_requests/create_service_spec.rb | 4 +- .../merge_requests/refresh_service_spec.rb | 4 +- ..._pipeline_for_merge_request_worker_spec.rb | 2 +- 25 files changed, 85 insertions(+), 62 deletions(-) create mode 100644 changelogs/unreleased/refactor-merge-request-between-pipeline-and-build.yml diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index c902e49ee6d..65962fba14d 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -46,7 +46,7 @@ module Ci delegate :terminal_specification, to: :runner_session, allow_nil: true delegate :gitlab_deploy_token, to: :project delegate :trigger_short_token, to: :trigger_request, allow_nil: true - delegate :merge_request?, to: :pipeline + delegate :merge_request_event?, to: :pipeline ## # Since Gitlab 11.5, deployments records started being created right after diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index ca941ca4331..317f965da1c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -60,9 +60,9 @@ module Ci validates :sha, presence: { unless: :importing? } validates :ref, presence: { unless: :importing? } - validates :merge_request, presence: { if: :merge_request? } - validates :merge_request, absence: { unless: :merge_request? } - validates :tag, inclusion: { in: [false], if: :merge_request? } + validates :merge_request, presence: { if: :merge_request_event? } + validates :merge_request, absence: { unless: :merge_request_event? } + validates :tag, inclusion: { in: [false], if: :merge_request_event? } validates :status, presence: { unless: :importing? } validate :valid_commit_sha, unless: :importing? validates :source, exclusion: { in: %w(unknown), unless: :importing? }, on: :create @@ -179,7 +179,7 @@ module Ci scope :sort_by_merge_request_pipelines, -> do sql = 'CASE ci_pipelines.source WHEN (?) THEN 0 ELSE 1 END, ci_pipelines.id DESC' - query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, sources[:merge_request]]) # rubocop:disable GitlabSecurity/PublicSend + query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, sources[:merge_request_event]]) # rubocop:disable GitlabSecurity/PublicSend order(query) end @@ -196,7 +196,7 @@ module Ci end scope :triggered_by_merge_request, -> (merge_request) do - where(source: :merge_request, merge_request: merge_request) + where(source: :merge_request_event, merge_request: merge_request) end scope :detached_merge_request_pipelines, -> (merge_request) do @@ -639,7 +639,7 @@ module Ci variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s) variables.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description.to_s) - if merge_request? && merge_request + if merge_request_event? && merge_request variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA', value: source_sha.to_s) variables.append(key: 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA', value: target_sha.to_s) variables.concat(merge_request.predefined_variables) @@ -669,7 +669,7 @@ module Ci # All the merge requests for which the current pipeline runs/ran against def all_merge_requests @all_merge_requests ||= - if merge_request? + if merge_request_event? MergeRequest.where(id: merge_request_id) else MergeRequest.where(source_project_id: project_id, source_branch: ref) @@ -714,7 +714,7 @@ module Ci # * nil: Modified path can not be evaluated def modified_paths strong_memoize(:modified_paths) do - if merge_request? + if merge_request_event? merge_request.modified_paths elsif branch_updated? push_details.modified_paths @@ -727,7 +727,7 @@ module Ci end def triggered_by_merge_request? - merge_request? && merge_request_id.present? + merge_request_event? && merge_request_id.present? end def detached_merge_request_pipeline? @@ -773,7 +773,7 @@ module Ci end def git_ref - if merge_request? + if merge_request_event? ## # In the future, we're going to change this ref to # merge request's merged reference, such as "refs/merge-requests/:iid/merge". diff --git a/app/models/ci/pipeline_enums.rb b/app/models/ci/pipeline_enums.rb index 4be4fdb1ff2..571c4271475 100644 --- a/app/models/ci/pipeline_enums.rb +++ b/app/models/ci/pipeline_enums.rb @@ -23,7 +23,7 @@ module Ci api: 5, external: 6, chat: 8, - merge_request: 10 + merge_request_event: 10 } end diff --git a/app/models/concerns/has_ref.rb b/app/models/concerns/has_ref.rb index 44b06b4890c..e0a48a930cb 100644 --- a/app/models/concerns/has_ref.rb +++ b/app/models/concerns/has_ref.rb @@ -4,7 +4,7 @@ module HasRef extend ActiveSupport::Concern def branch? - !tag? && !merge_request? + !tag? && !merge_request_event? end def git_ref diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index d60281c8a0b..29656b17183 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -35,7 +35,7 @@ module Ci specs = [] if git_depth > 0 - specs << refspec_for_branch(ref) if branch? || merge_request? + specs << refspec_for_branch(ref) if branch? || merge_request_event? specs << refspec_for_tag(ref) if tag? else specs << refspec_for_branch diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb index 29b1a6c244b..c2990cb5159 100644 --- a/app/serializers/pipeline_entity.rb +++ b/app/serializers/pipeline_entity.rb @@ -23,7 +23,7 @@ class PipelineEntity < Grape::Entity expose :latest?, as: :latest expose :stuck?, as: :stuck expose :auto_devops_source?, as: :auto_devops - expose :merge_request?, as: :merge_request + expose :merge_request_event?, as: :merge_request expose :has_yaml_errors?, as: :yaml_errors expose :can_retry?, as: :retryable expose :can_cancel?, as: :cancelable @@ -49,7 +49,7 @@ class PipelineEntity < Grape::Entity expose :tag?, as: :tag expose :branch?, as: :branch - expose :merge_request?, as: :merge_request + expose :merge_request_event?, as: :merge_request end expose :commit, using: CommitEntity diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index ac51fee0b3f..11ede5223e5 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -67,7 +67,7 @@ module MergeRequests Ci::CreatePipelineService .new(merge_request.source_project, user, ref: merge_request.source_branch) - .execute(:merge_request, + .execute(:merge_request_event, ignore_skip_ci: true, save_on_errors: false, merge_request: merge_request) diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 9c2efd6aa35..55adeb345ab 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -48,7 +48,7 @@ content: "#{popover_content_text}", } } Auto DevOps - - if @pipeline.merge_request? + - if @pipeline.merge_request_event? %span.js-pipeline-url-mergerequest.badge.badge-info.has-tooltip{ title: "This pipeline is run in a merge request context" } merge request - if @pipeline.stuck? diff --git a/changelogs/unreleased/refactor-merge-request-between-pipeline-and-build.yml b/changelogs/unreleased/refactor-merge-request-between-pipeline-and-build.yml new file mode 100644 index 00000000000..bf78f8d84a6 --- /dev/null +++ b/changelogs/unreleased/refactor-merge-request-between-pipeline-and-build.yml @@ -0,0 +1,5 @@ +--- +title: Add suffix (`_event`) to merge request source +merge_request: 25508 +author: +type: other diff --git a/lib/gitlab/ci/build/policy/refs.rb b/lib/gitlab/ci/build/policy/refs.rb index 0e9bb5c94bb..df5f5ffc253 100644 --- a/lib/gitlab/ci/build/policy/refs.rb +++ b/lib/gitlab/ci/build/policy/refs.rb @@ -29,8 +29,8 @@ module Gitlab def matches_pattern?(pattern, pipeline) return true if pipeline.tag? && pattern == 'tags' return true if pipeline.branch? && pattern == 'branches' - return true if pipeline.source == pattern - return true if pipeline.source&.pluralize == pattern + return true if sanitized_source_name(pipeline) == pattern + return true if sanitized_source_name(pipeline)&.pluralize == pattern # patterns can be matched only when branch or tag is used # the pattern matching does not work for merge requests pipelines @@ -42,6 +42,10 @@ module Gitlab end end end + + def sanitized_source_name(pipeline) + @sanitized_source_name ||= pipeline&.source&.delete_suffix('_event') + end end end end diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index 0c0c5fc8a4c..18f724770b5 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -104,7 +104,7 @@ FactoryBot.define do trait :with_merge_request_pipeline do after(:build) do |merge_request| merge_request.merge_request_pipelines << build(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, merge_request: merge_request, project: merge_request.source_project) end diff --git a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb index 7b473faa884..97b2aa82fce 100644 --- a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb @@ -49,7 +49,7 @@ describe 'Merge request > User sees merge request pipelines', :js do let!(:merge_request_pipeline) do Ci::CreatePipelineService.new(project, user, ref: 'feature') - .execute(:merge_request, merge_request: merge_request) + .execute(:merge_request_event, merge_request: merge_request) end before do @@ -81,7 +81,7 @@ describe 'Merge request > User sees merge request pipelines', :js do let!(:merge_request_pipeline_2) do Ci::CreatePipelineService.new(project, user, ref: 'feature') - .execute(:merge_request, merge_request: merge_request) + .execute(:merge_request_event, merge_request: merge_request) end before do @@ -220,7 +220,7 @@ describe 'Merge request > User sees merge request pipelines', :js do let!(:merge_request_pipeline) do Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature') - .execute(:merge_request, merge_request: merge_request) + .execute(:merge_request_event, merge_request: merge_request) end let(:forked_project) { fork_project(project, user2, repository: true) } @@ -263,7 +263,7 @@ describe 'Merge request > User sees merge request pipelines', :js do let!(:merge_request_pipeline_2) do Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature') - .execute(:merge_request, merge_request: merge_request) + .execute(:merge_request_event, merge_request: merge_request) end before do diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 72ef460d315..36b8c15b8b6 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -666,7 +666,7 @@ describe 'Pipeline', :js do let(:pipeline) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, project: merge_request.source_project, ref: 'feature', sha: merge_request.diff_head_sha, diff --git a/spec/lib/gitlab/ci/build/policy/changes_spec.rb b/spec/lib/gitlab/ci/build/policy/changes_spec.rb index dc3329061d1..92cf0376c02 100644 --- a/spec/lib/gitlab/ci/build/policy/changes_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/changes_spec.rb @@ -133,7 +133,7 @@ describe Gitlab::Ci::Build::Policy::Changes do let(:seed) { double('build seed', to_resource: ci_build) } context 'when source is merge request' do - let(:source) { :merge_request } + let(:source) { :merge_request_event } let(:merge_request) do create(:merge_request, diff --git a/spec/lib/gitlab/ci/build/policy/refs_spec.rb b/spec/lib/gitlab/ci/build/policy/refs_spec.rb index 553fc0fb9bf..b4ddbf89b70 100644 --- a/spec/lib/gitlab/ci/build/policy/refs_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/refs_spec.rb @@ -68,6 +68,20 @@ describe Gitlab::Ci::Build::Policy::Refs do expect(described_class.new(%w[triggers])) .not_to be_satisfied_by(pipeline) end + + context 'when source is merge_request_event' do + let(:pipeline) { build_stubbed(:ci_pipeline, source: :merge_request_event) } + + it 'is satisfied with only: merge_request' do + expect(described_class.new(%w[merge_requests])) + .to be_satisfied_by(pipeline) + end + + it 'is not satisfied with only: merge_request_event' do + expect(described_class.new(%w[merge_request_events])) + .not_to be_satisfied_by(pipeline) + end + end end context 'when matching a ref by a regular expression' do diff --git a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb index c9d1d09a938..3debd42ac65 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb @@ -96,7 +96,7 @@ describe Gitlab::Ci::Pipeline::Chain::Build do context 'when pipeline is running for a merge request' do let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( - source: :merge_request, + source: :merge_request_event, origin_ref: 'feature', checkout_sha: project.commit.id, after_sha: nil, @@ -117,7 +117,7 @@ describe Gitlab::Ci::Pipeline::Chain::Build do end it 'correctly indicated that this is a merge request pipeline' do - expect(pipeline).to be_merge_request + expect(pipeline).to be_merge_request_event expect(pipeline.merge_request).to eq(merge_request) end diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb index 053bc421649..e6c6a82b463 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb @@ -115,7 +115,7 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do let(:pipeline) { build_stubbed(:ci_pipeline, project: project) } let(:merge_request_pipeline) do - build(:ci_pipeline, source: :merge_request, project: project) + build(:ci_pipeline, source: :merge_request_event, project: project) end let(:chain) { described_class.new(merge_request_pipeline, command).tap(&:perform!) } diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index e5281f3a09e..fc75d3e23fb 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -23,7 +23,7 @@ describe Ci::Build do it { is_expected.to validate_presence_of(:ref) } it { is_expected.to respond_to(:has_trace?) } it { is_expected.to respond_to(:trace) } - it { is_expected.to delegate_method(:merge_request?).to(:pipeline) } + it { is_expected.to delegate_method(:merge_request_event?).to(:pipeline) } it { is_expected.to be_a(ArtifactMigratable) } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index ee400bec04b..462793b259b 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -80,11 +80,11 @@ describe Ci::Pipeline, :mailer do context 'when merge request pipelines exist' do let!(:merge_request_pipeline_1) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let!(:merge_request_pipeline_2) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let(:merge_request) do @@ -106,11 +106,11 @@ describe Ci::Pipeline, :mailer do let!(:branch_pipeline_2) { create(:ci_pipeline, source: :push) } let!(:merge_request_pipeline_1) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let!(:merge_request_pipeline_2) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let(:merge_request) do @@ -134,7 +134,7 @@ describe Ci::Pipeline, :mailer do subject { described_class.detached_merge_request_pipelines(merge_request) } let!(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request, target_sha: target_sha) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request, target_sha: target_sha) end let(:merge_request) { create(:merge_request) } @@ -157,7 +157,7 @@ describe Ci::Pipeline, :mailer do subject { pipeline.detached_merge_request_pipeline? } let!(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request, target_sha: target_sha) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request, target_sha: target_sha) end let(:merge_request) { create(:merge_request) } @@ -176,7 +176,7 @@ describe Ci::Pipeline, :mailer do subject { described_class.merge_request_pipelines(merge_request) } let!(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request, target_sha: target_sha) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request, target_sha: target_sha) end let(:merge_request) { create(:merge_request) } @@ -199,7 +199,7 @@ describe Ci::Pipeline, :mailer do subject { pipeline.merge_request_pipeline? } let!(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request, target_sha: target_sha) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request, target_sha: target_sha) end let(:merge_request) { create(:merge_request) } @@ -218,7 +218,7 @@ describe Ci::Pipeline, :mailer do subject { described_class.mergeable_merge_request_pipelines(merge_request) } let!(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request, target_sha: target_sha) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request, target_sha: target_sha) end let(:merge_request) { create(:merge_request) } @@ -241,7 +241,7 @@ describe Ci::Pipeline, :mailer do subject { pipeline.mergeable_merge_request_pipeline? } let!(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request, target_sha: target_sha) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request, target_sha: target_sha) end let(:merge_request) { create(:merge_request) } @@ -256,11 +256,11 @@ describe Ci::Pipeline, :mailer do end end - describe '.merge_request' do - subject { described_class.merge_request } + describe '.merge_request_event' do + subject { described_class.merge_request_event } context 'when there is a merge request pipeline' do - let!(:pipeline) { create(:ci_pipeline, source: :merge_request, merge_request: merge_request) } + let!(:pipeline) { create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) } let(:merge_request) { create(:merge_request) } it 'returns merge request pipeline first' do @@ -281,7 +281,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { build(:ci_pipeline, source: source, merge_request: merge_request) } context 'when source is merge request' do - let(:source) { :merge_request } + let(:source) { :merge_request_event } context 'when merge request is specified' do let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_project: project, target_branch: 'master') } @@ -505,7 +505,7 @@ describe Ci::Pipeline, :mailer do context 'when source is merge request' do let(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let(:merge_request) do @@ -1097,7 +1097,7 @@ describe Ci::Pipeline, :mailer do context 'when source is merge request' do let(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let(:merge_request) do @@ -1147,7 +1147,7 @@ describe Ci::Pipeline, :mailer do context 'when ref is merge request' do let(:pipeline) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, merge_request: merge_request) end @@ -1310,7 +1310,7 @@ describe Ci::Pipeline, :mailer do context 'when source is merge request' do let(:pipeline) do - create(:ci_pipeline, source: :merge_request, merge_request: merge_request) + create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) end let(:merge_request) do @@ -2266,7 +2266,7 @@ describe Ci::Pipeline, :mailer do let!(:pipeline) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, project: pipeline_project, ref: source_branch, merge_request: merge_request) @@ -2289,7 +2289,7 @@ describe Ci::Pipeline, :mailer do let!(:pipeline_2) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, project: pipeline_project, ref: source_branch, merge_request: merge_request_2) diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 82a853a23b9..07cb4c9c1e3 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1333,7 +1333,7 @@ describe MergeRequest do let!(:merge_request_pipeline) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, project: project, ref: source_ref, sha: shas.second, @@ -1372,7 +1372,7 @@ describe MergeRequest do let!(:merge_request_pipeline_2) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, project: project, ref: source_ref, sha: shas.first, @@ -1399,7 +1399,7 @@ describe MergeRequest do let!(:merge_request_pipeline_2) do create(:ci_pipeline, - source: :merge_request, + source: :merge_request_event, project: project, ref: source_ref, sha: shas.first, diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 43c06f7c973..9087cccb759 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -549,7 +549,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end context 'when job is made for merge request' do - let(:pipeline) { create(:ci_pipeline_without_jobs, source: :merge_request, project: project, ref: 'feature', merge_request: merge_request) } + let(:pipeline) { create(:ci_pipeline_without_jobs, source: :merge_request_event, project: project, ref: 'feature', merge_request: merge_request) } let!(:job) { create(:ci_build, pipeline: pipeline, name: 'spinach', ref: 'feature', stage: 'test', stage_idx: 0) } let(:merge_request) { create(:merge_request) } diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 93349ba7b5b..24707cd2d41 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -701,7 +701,7 @@ describe Ci::CreatePipelineService do let(:target_sha) { nil } context 'when source is merge request' do - let(:source) { :merge_request } + let(:source) { :merge_request_event } context "when config has merge_requests keywords" do let(:config) do @@ -734,7 +734,7 @@ describe Ci::CreatePipelineService do it 'creates a merge request pipeline' do expect(pipeline).to be_persisted - expect(pipeline).to be_merge_request + expect(pipeline).to be_merge_request_event expect(pipeline.merge_request).to eq(merge_request) expect(pipeline.builds.order(:stage_id).map(&:name)).to eq(%w[test]) end diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index b46aa65818d..a04a4d5fc36 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -194,7 +194,7 @@ describe MergeRequests::CreateService do merge_request.reload expect(merge_request.merge_request_pipelines.count).to eq(1) - expect(merge_request.actual_head_pipeline).to be_merge_request + expect(merge_request.actual_head_pipeline).to be_merge_request_event end context 'when there are no commits between source branch and target branch' do @@ -226,7 +226,7 @@ describe MergeRequests::CreateService do end it 'sets the latest merge request pipeline as the head pipeline' do - expect(merge_request.actual_head_pipeline).to be_merge_request + expect(merge_request.actual_head_pipeline).to be_merge_request_event end end diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 9e9dc5a576c..43ceb1dcbee 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -173,12 +173,12 @@ describe MergeRequests::RefreshService do it 'sets the latest merge request pipeline as a head pipeline' do @merge_request.reload - expect(@merge_request.actual_head_pipeline).to be_merge_request + expect(@merge_request.actual_head_pipeline).to be_merge_request_event end it 'returns pipelines in correct order' do @merge_request.reload - expect(@merge_request.all_pipelines.first).to be_merge_request + expect(@merge_request.all_pipelines.first).to be_merge_request_event expect(@merge_request.all_pipelines.second).to be_push end end diff --git a/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb b/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb index 963237ceadf..a13a3046f55 100644 --- a/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb +++ b/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb @@ -39,7 +39,7 @@ describe UpdateHeadPipelineForMergeRequestWorker do let!(:merge_request_pipeline) do create(:ci_pipeline, project: project, - source: :merge_request, + source: :merge_request_event, sha: latest_sha, merge_request: merge_request) end