diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-02-25 14:05:26 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-03-01 16:52:38 +0300 |
commit | f62dc67d262792829bdcaef779b3915e9cc93a4f (patch) | |
tree | f9419e96914addb59dfa4ab653c9c6151b33e4e2 /spec | |
parent | dc5fc28382246fbbe2bb6f61fe8dac136b5f3189 (diff) |
Add suffix for merge request event
Fix
ok
Add spec
Fix
ok
Fix
Add changelog
Fix
Add memoization
a
fix
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/merge_requests.rb | 2 | ||||
-rw-r--r-- | spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb | 8 | ||||
-rw-r--r-- | spec/features/projects/pipelines/pipeline_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/build/policy/changes_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/build/policy/refs_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/build_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 40 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/merge_requests/create_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb | 2 |
15 files changed, 56 insertions, 42 deletions
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 |