diff options
Diffstat (limited to 'spec/serializers/merge_request_poll_cached_widget_entity_spec.rb')
-rw-r--r-- | spec/serializers/merge_request_poll_cached_widget_entity_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb b/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb index 380e20905c6..cad3d2e3373 100644 --- a/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb +++ b/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb @@ -268,4 +268,49 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do end end end + + describe 'merge_pipeline' do + it 'returns nil' do + expect(subject[:merge_pipeline]).to be_nil + end + + context 'when is merged' do + let(:resource) { create(:merged_merge_request, source_project: project, merge_commit_sha: project.commit.id) } + let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: resource.target_branch, sha: resource.merge_commit_sha) } + + before do + project.add_maintainer(user) + end + + it 'returns merge_pipeline' do + pipeline.reload + pipeline_payload = + MergeRequests::PipelineEntity + .represent(pipeline, request: request) + .as_json + + expect(subject[:merge_pipeline]).to eq(pipeline_payload) + end + + context 'when user cannot read pipelines on target project' do + before do + project.add_guest(user) + end + + it 'returns nil' do + expect(subject[:merge_pipeline]).to be_nil + end + end + + context 'when merge_request_cached_merge_pipeline_serializer is disabled' do + before do + stub_feature_flags(merge_request_cached_merge_pipeline_serializer: false) + end + + it 'returns nil' do + expect(subject[:merge_pipeline]).to be_nil + end + end + end + end end |