Commit 1cbbe4d8 authored by Phil Hughes's avatar Phil Hughes

Moves widget Gitaly call from page load to an async request

This moves a Gitaly request from on page load to be inside
of the already loading async request.
parent c603c647
......@@ -104,6 +104,16 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
presenter(merge_request).api_unapprove_path
end
expose :blob_path do
expose :head_path, if: -> (mr, _) { mr.source_branch_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.source_branch_sha)
end
expose :base_path, if: -> (mr, _) { mr.diff_base_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.diff_base_sha)
end
end
private
delegate :current_user, to: :request
......
......@@ -115,16 +115,6 @@ class MergeRequestWidgetEntity < Grape::Entity
end
end
expose :blob_path do
expose :head_path, if: -> (mr, _) { mr.source_branch_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.source_branch_sha)
end
expose :base_path, if: -> (mr, _) { mr.diff_base_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.diff_base_sha)
end
end
expose :codeclimate, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:codequality) } do
expose :head_path do |merge_request|
head_pipeline_downloadable_path_for_report_type(:codequality)
......
......@@ -8,6 +8,7 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
let_it_be(:project, refind: true) { create :project, :repository }
let_it_be(:resource, refind: true) { create(:merge_request, source_project: project, target_project: project) }
let_it_be(:user) { create(:user) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:request) { double('request', current_user: user, project: project) }
......@@ -25,6 +26,17 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
expect(subject[:merge_status]).to eq 'checking'
end
it 'has blob path data' do
allow(resource).to receive_messages(
base_pipeline: pipeline,
head_pipeline: pipeline
)
expect(subject).to include(:blob_path)
expect(subject[:blob_path]).to include(:base_path)
expect(subject[:blob_path]).to include(:head_path)
end
describe 'diverged_commits_count' do
context 'when MR open and its diverging' do
it 'returns diverged commits count' do
......
......@@ -76,17 +76,6 @@ RSpec.describe MergeRequestWidgetEntity do
.to eq("/#{resource.project.full_path}/-/merge_requests/#{resource.iid}.diff")
end
it 'has blob path data' do
allow(resource).to receive_messages(
base_pipeline: pipeline,
head_pipeline: pipeline
)
expect(subject).to include(:blob_path)
expect(subject[:blob_path]).to include(:base_path)
expect(subject[:blob_path]).to include(:head_path)
end
describe 'codequality report artifacts', :request_store do
let(:merge_base_pipeline) { create(:ci_pipeline, :with_codequality_report, project: project) }
......
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