diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-05-22 18:45:27 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-06-03 13:15:29 +0700 |
commit | d4b46936633a3b2a0248b4572b4a1dc7b2ba8531 (patch) | |
tree | bf5c1cf5a8ebf1568ca62576d63ff793ce29764f /spec/serializers | |
parent | 96744d0befd7e298c08e6d20a4f504086a717c35 (diff) | |
download | gitlab-ce-d4b46936633a3b2a0248b4572b4a1dc7b2ba8531.tar.gz |
Abstract auto merge processes
We have one auto merge strategy today - Merge When Pipeline
Succeeds.
In order to add more strategies for Merge Train feature,
we abstract the architecture to be more extensible.
Removed arguments
Fix spec
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/merge_request_widget_entity_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb index b89898f26f7..a27c22191f4 100644 --- a/spec/serializers/merge_request_widget_entity_spec.rb +++ b/spec/serializers/merge_request_widget_entity_spec.rb @@ -297,4 +297,50 @@ describe MergeRequestWidgetEntity do end end end + + describe 'auto merge' do + context 'when auto merge is enabled' do + let(:resource) { create(:merge_request, :merge_when_pipeline_succeeds) } + + it 'returns auto merge related information' do + expect(subject[:auto_merge_enabled]).to be_truthy + expect(subject[:auto_merge_strategy]).to eq('merge_when_pipeline_succeeds') + end + end + + context 'when auto merge is not enabled' do + let(:resource) { create(:merge_request) } + + it 'returns auto merge related information' do + expect(subject[:auto_merge_enabled]).to be_falsy + expect(subject[:auto_merge_strategy]).to be_nil + end + end + + context 'when head pipeline is running' do + before do + create(:ci_pipeline, :running, project: project, + ref: resource.source_branch, + sha: resource.diff_head_sha) + resource.update_head_pipeline + end + + it 'returns available auto merge strategies' do + expect(subject[:available_auto_merge_strategies]).to eq(%w[merge_when_pipeline_succeeds]) + end + end + + context 'when head pipeline is finished' do + before do + create(:ci_pipeline, :success, project: project, + ref: resource.source_branch, + sha: resource.diff_head_sha) + resource.update_head_pipeline + end + + it 'returns available auto merge strategies' do + expect(subject[:available_auto_merge_strategies]).to be_empty + end + end + end end |