diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 15:08:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 15:08:49 +0300 |
commit | 1308dc5eb484ab0f8064989fc551ebdb4b1a7976 (patch) | |
tree | 614a93d9bf8df34ecfc25c02648329987fb21dde /spec/models/ci | |
parent | f0707f413ce49b5712fca236b950acbec029be1e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/build_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 69 |
2 files changed, 23 insertions, 48 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 8f2626037a1..65fd9b049d6 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -33,7 +33,7 @@ describe Ci::Build do it { is_expected.to respond_to(:has_trace?) } it { is_expected.to respond_to(:trace) } - it { is_expected.to delegate_method(:merge_request_event?).to(:pipeline) } + it { is_expected.to delegate_method(:merge_request?).to(:pipeline) } it { is_expected.to delegate_method(:merge_request_ref?).to(:pipeline) } it { is_expected.to delegate_method(:legacy_detached_merge_request_pipeline?).to(:pipeline) } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 42d304d9116..1515da7eeca 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -162,6 +162,23 @@ describe Ci::Pipeline, :mailer do end end + describe '#merge_request?' do + let(:pipeline) { create(:ci_pipeline, merge_request: merge_request) } + let(:merge_request) { create(:merge_request) } + + it 'returns true' do + expect(pipeline).to be_merge_request + end + + context 'when merge request is nil' do + let(:merge_request) { nil } + + it 'returns false' do + expect(pipeline).not_to be_merge_request + end + end + end + describe '#detached_merge_request_pipeline?' do subject { pipeline.detached_merge_request_pipeline? } @@ -367,48 +384,6 @@ describe Ci::Pipeline, :mailer do end end - describe 'Validations for merge request pipelines' do - let(:pipeline) do - build(:ci_pipeline, source: source, merge_request: merge_request) - end - - let(:merge_request) do - create(:merge_request, - source_project: project, - source_branch: 'feature', - target_project: project, - target_branch: 'master') - end - - context 'when source is merge request' do - let(:source) { :merge_request_event } - - context 'when merge request is specified' do - it { expect(pipeline).to be_valid } - end - - context 'when merge request is empty' do - let(:merge_request) { nil } - - it { expect(pipeline).not_to be_valid } - end - end - - context 'when source is web' do - let(:source) { :web } - - context 'when merge request is specified' do - it { expect(pipeline).not_to be_valid } - end - - context 'when merge request is empty' do - let(:merge_request) { nil } - - it { expect(pipeline).to be_valid } - end - end - end - describe 'modules' do it_behaves_like 'AtomicInternalId', validate_presence: false do let(:internal_id_attribute) { :iid } @@ -612,9 +587,9 @@ describe Ci::Pipeline, :mailer do ] end - context 'when source is merge request' do + context 'when pipeline is merge request' do let(:pipeline) do - create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) + create(:ci_pipeline, merge_request: merge_request) end let(:merge_request) do @@ -651,7 +626,7 @@ describe Ci::Pipeline, :mailer do 'CI_MERGE_REQUEST_TITLE' => merge_request.title, 'CI_MERGE_REQUEST_ASSIGNEES' => merge_request.assignee_username_list, 'CI_MERGE_REQUEST_MILESTONE' => milestone.title, - 'CI_MERGE_REQUEST_LABELS' => labels.map(&:title).join(','), + 'CI_MERGE_REQUEST_LABELS' => labels.map(&:title).sort.join(','), 'CI_MERGE_REQUEST_EVENT_TYPE' => pipeline.merge_request_event_type.to_s) end @@ -1263,9 +1238,9 @@ describe Ci::Pipeline, :mailer do is_expected.to be_truthy end - context 'when source is merge request' do + context 'when pipeline is merge request' do let(:pipeline) do - create(:ci_pipeline, source: :merge_request_event, merge_request: merge_request) + create(:ci_pipeline, merge_request: merge_request) end let(:merge_request) do |