Commit e815a2ff authored by Sean McGivern's avatar Sean McGivern

Merge branch 'id-remove-first-async-mergeability-check' into 'master'

Calculate mergeability check sync on first widget load

See merge request gitlab-org/gitlab!63506
parents 2f9eec2f 46ffa7b8
......@@ -14,8 +14,6 @@ class Projects::MergeRequests::ContentController < Projects::MergeRequests::Appl
SLOW_POLLING_INTERVAL = 5.minutes.in_milliseconds
def widget
check_mergeability_async!
respond_to do |format|
format.json do
render json: serializer(MergeRequestPollWidgetEntity)
......@@ -40,13 +38,6 @@ class Projects::MergeRequests::ContentController < Projects::MergeRequests::Appl
def serializer(entity)
serializer = MergeRequestSerializer.new(current_user: current_user, project: merge_request.project)
serializer.represent(merge_request, { async_mergeability_check: params[:async_mergeability_check] }, entity)
end
def check_mergeability_async!
return unless Feature.enabled?(:check_mergeability_async_in_widget, merge_request.project, default_enabled: :yaml)
return if params[:async_mergeability_check].blank?
merge_request.check_mergeability(async: true)
serializer.represent(merge_request, {}, entity)
end
end
......@@ -31,7 +31,6 @@ class MergeRequestPollWidgetEntity < Grape::Entity
expose :mergeable do |merge_request, options|
next merge_request.mergeable? if Feature.disabled?(:check_mergeability_async_in_widget, merge_request.project, default_enabled: :yaml)
next false if options[:async_mergeability_check].present? && merge_request.checking?
merge_request.mergeable?
end
......
......@@ -36,7 +36,7 @@ class MergeRequestWidgetEntity < Grape::Entity
end
expose :merge_request_widget_path do |merge_request|
widget_project_json_merge_request_path(merge_request.target_project, merge_request, async_mergeability_check: true, format: :json)
widget_project_json_merge_request_path(merge_request.target_project, merge_request, format: :json)
end
expose :merge_request_cached_widget_path do |merge_request|
......
......@@ -62,7 +62,7 @@
- add_page_startup_api_call notes_url
- else
- add_page_startup_api_call discussions_path(@merge_request)
- add_page_startup_api_call widget_project_json_merge_request_path(@project, @merge_request, async_mergeability_check: true, format: :json)
- add_page_startup_api_call widget_project_json_merge_request_path(@project, @merge_request, format: :json)
- add_page_startup_api_call cached_widget_project_json_merge_request_path(@project, @merge_request, format: :json)
#js-vue-mr-discussions{ data: { notes_data: notes_data(@merge_request, Feature.enabled?(:paginated_notes, @project)).to_json,
endpoint_metadata: @endpoint_metadata_url,
......
......@@ -57,17 +57,6 @@ RSpec.describe Projects::MergeRequests::ContentController do
expect(response.headers['Poll-Interval']).to eq('10000')
end
context 'when async_mergeability_check param is passed' do
it 'checks mergeability asynchronously' do
expect_next_instance_of(MergeRequests::MergeabilityCheckService) do |service|
expect(service).not_to receive(:execute)
expect(service).to receive(:async_execute).and_call_original
end
do_request(:widget, { async_mergeability_check: true })
end
end
context 'merged merge request' do
let(:merge_request) do
create(:merged_merge_request, :with_test_reports, target_project: project, source_project: project)
......
......@@ -229,21 +229,13 @@ RSpec.describe MergeRequestPollWidgetEntity do
expect(subject[:mergeable]).to eq(true)
end
context 'when async_mergeability_check is passed' do
let(:options) { { async_mergeability_check: true } }
it 'returns false' do
expect(subject[:mergeable]).to eq(false)
context 'when check_mergeability_async_in_widget is disabled' do
before do
stub_feature_flags(check_mergeability_async_in_widget: false)
end
context 'when check_mergeability_async_in_widget is disabled' do
before do
stub_feature_flags(check_mergeability_async_in_widget: false)
end
it 'calculates mergeability and returns true' do
expect(subject[:mergeable]).to eq(true)
end
it 'calculates mergeability and returns true' do
expect(subject[:mergeable]).to eq(true)
end
end
end
......
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