Commit c384cc6f authored by Phil Hughes's avatar Phil Hughes

Fix blocking merge requests not unblocking merge button

Fixes a bug where when a blocking merge request gets merged
the widget will not allow for the merge request
to be merged.
parent 8d2c34da
......@@ -36,7 +36,10 @@ export default {
return this.restructuredWidgetShowMergeButtons;
}
if (this.mr.blockingMergeRequests?.total_count > 0) {
if (
(this.mr.blockingMergeRequests?.visible_merge_requests?.merged?.length || 0) !==
(this.mr.blockingMergeRequests?.total_count || 0)
) {
return false;
}
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "User views merge request with blocking merge requests", :js do
let(:merge_request) { create(:merge_request) }
let(:user) { merge_request.target_project.first_owner }
let(:other_mr) { create(:merge_request) }
before do
stub_licensed_features(blocking_merge_requests: true)
other_mr.target_project.team.add_developer(user)
create(:merge_request_block, blocking_merge_request: other_mr, blocked_merge_request: merge_request)
sign_in(user)
visit merge_request_path(merge_request)
end
it 'disables merge button when blocking merge request is open' do
page.within('.mr-widget-section') do
expect(page).to have_content('Merge blocked: all merge request dependencies must be merged or closed.')
end
end
context 'merged blocking merge request' do
let(:other_mr) { create(:merge_request, state: :merged) }
it 'enables merge button when blocking merge request is merged' do
page.within('.mr-widget-section') do
expect(page).not_to have_content('Merge blocked: all merge request dependencies must be merged or closed.')
end
end
end
end
......@@ -375,17 +375,18 @@ describe('ReadyToMerge', () => {
});
it.each`
disabled | disabledText | totalCount
${'true'} | ${'disable'} | ${1}
${undefined} | ${'enable'} | ${0}
disabled | disabledText | totalCount | mergedCount
${'true'} | ${'disable'} | ${1} | ${0}
${undefined} | ${'enable'} | ${1} | ${1}
`(
'should $disabledText merge button blockingMergeRequests.total_count is $totalCount',
({ disabled, totalCount }) => {
'should $disabledText merge button blockingMergeRequests.total_count is $totalCount and merged is $mergedCount',
({ disabled, totalCount, mergedCount }) => {
factory({
isMergeAllowed: true,
availableAutoMergeStrategies: [],
blockingMergeRequests: {
total_count: totalCount,
visible_merge_requests: { merged: new Array(mergedCount) },
},
});
......
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