Commit 4cb1e110 authored by Igor Drozdov's avatar Igor Drozdov

Move CI related paths to cached MR widget

We have invalidation mechanisms for CI pipelines
that keep MR widget up-to-date.
parent a7905879
...@@ -110,6 +110,36 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity ...@@ -110,6 +110,36 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
presenter(merge_request).api_unapprove_path presenter(merge_request).api_unapprove_path
end end
expose :test_reports_path do |merge_request|
if merge_request.has_test_reports?
test_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :accessibility_report_path do |merge_request|
if merge_request.has_accessibility_reports?
accessibility_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :codequality_reports_path do |merge_request|
if merge_request.has_codequality_reports?
codequality_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :terraform_reports_path do |merge_request|
if merge_request.has_terraform_reports?
terraform_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :exposed_artifacts_path do |merge_request|
if merge_request.has_exposed_artifacts?
exposed_artifacts_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :blob_path do expose :blob_path do
expose :head_path, if: -> (mr, _) { mr.source_branch_sha } do |merge_request| expose :head_path, if: -> (mr, _) { mr.source_branch_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.source_branch_sha) project_blob_path(merge_request.project, merge_request.source_branch_sha)
......
...@@ -71,36 +71,6 @@ class MergeRequestPollWidgetEntity < Grape::Entity ...@@ -71,36 +71,6 @@ class MergeRequestPollWidgetEntity < Grape::Entity
presenter(merge_request).cancel_auto_merge_path presenter(merge_request).cancel_auto_merge_path
end end
expose :test_reports_path do |merge_request|
if merge_request.has_test_reports?
test_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :accessibility_report_path do |merge_request|
if merge_request.has_accessibility_reports?
accessibility_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :codequality_reports_path do |merge_request|
if merge_request.has_codequality_reports?
codequality_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :terraform_reports_path do |merge_request|
if merge_request.has_terraform_reports?
terraform_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :exposed_artifacts_path do |merge_request|
if merge_request.has_exposed_artifacts?
exposed_artifacts_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :create_issue_to_resolve_discussions_path do |merge_request| expose :create_issue_to_resolve_discussions_path do |merge_request|
presenter(merge_request).create_issue_to_resolve_discussions_path presenter(merge_request).create_issue_to_resolve_discussions_path
end end
......
---
title: Move CI related paths to cached MR widget
merge_request: 58711
author:
type: performance
...@@ -313,4 +313,38 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do ...@@ -313,4 +313,38 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
end end
end end
end end
describe 'ci related paths' do
using RSpec::Parameterized::TableSyntax
where(:path_field, :method_for_existence_check) do
:terraform_reports_path | :has_terraform_reports?
:accessibility_report_path | :has_accessibility_reports?
:exposed_artifacts_path | :has_exposed_artifacts?
:test_reports_path | :has_test_reports?
:codequality_reports_path | :has_codequality_reports?
end
with_them do
context 'when merge request has reports' do
before do
allow(resource).to receive(method_for_existence_check).and_return(true)
end
it 'set the path to poll data' do
expect(subject[path_field]).to be_present
end
end
context 'when merge request has no reports' do
before do
allow(resource).to receive(method_for_existence_check).and_return(false)
end
it 'does not set reports path' do
expect(subject[path_field]).to be_nil
end
end
end
end
end end
...@@ -86,72 +86,6 @@ RSpec.describe MergeRequestPollWidgetEntity do ...@@ -86,72 +86,6 @@ RSpec.describe MergeRequestPollWidgetEntity do
end end
end end
describe 'terraform_reports_path' do
context 'when merge request has terraform reports' do
before do
allow(resource).to receive(:has_terraform_reports?).and_return(true)
end
it 'set the path to poll data' do
expect(subject[:terraform_reports_path]).to be_present
end
end
context 'when merge request has no terraform reports' do
before do
allow(resource).to receive(:has_terraform_reports?).and_return(false)
end
it 'set the path to poll data' do
expect(subject[:terraform_reports_path]).to be_nil
end
end
end
describe 'accessibility_report_path' do
context 'when merge request has accessibility reports' do
before do
allow(resource).to receive(:has_accessibility_reports?).and_return(true)
end
it 'set the path to poll data' do
expect(subject[:accessibility_report_path]).to be_present
end
end
context 'when merge request has no accessibility reports' do
before do
allow(resource).to receive(:has_accessibility_reports?).and_return(false)
end
it 'set the path to poll data' do
expect(subject[:accessibility_report_path]).to be_nil
end
end
end
describe 'exposed_artifacts_path' do
context 'when merge request has exposed artifacts' do
before do
expect(resource).to receive(:has_exposed_artifacts?).and_return(true)
end
it 'set the path to poll data' do
expect(subject[:exposed_artifacts_path]).to be_present
end
end
context 'when merge request has no exposed artifacts' do
before do
expect(resource).to receive(:has_exposed_artifacts?).and_return(false)
end
it 'set the path to poll data' do
expect(subject[:exposed_artifacts_path]).to be_nil
end
end
end
describe 'auto merge' do describe 'auto merge' do
before do before do
project.add_maintainer(user) project.add_maintainer(user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment