Commit 71026ffd authored by Robert Speicher's avatar Robert Speicher

Merge branch...

Merge branch '56093-11-7-rc2-prevents-people-from-merging-merge-requests-even-when-they-should-be-able-to' into 'master'

Fix MR sidebar to correctly warning if assignee can't merge

Closes #56093

See merge request gitlab-org/gitlab-ce!24243
parents 1b3affaf d403d7ac
......@@ -25,7 +25,7 @@
.value.hide-collapsed
- if issuable_sidebar[:assignee]
= link_to_member(@project, assignee, size: 32, extra_class: 'bold') do
- if issuable_sidebar[:assignee][:can_merge]
- unless issuable_sidebar[:assignee][:can_merge]
%span.float-right.cannot-be-merged{ data: { toggle: 'tooltip', placement: 'left' }, title: _('Not allowed to merge') }
= icon('exclamation-triangle', 'aria-hidden': 'true')
%span.username
......
......@@ -32,11 +32,7 @@ describe 'projects/merge_requests/show.html.haml' do
assign(:noteable, closed_merge_request)
assign(:notes, [])
assign(:pipelines, Ci::Pipeline.none)
assign(
:issuable_sidebar,
MergeRequestSerializer.new(current_user: user, project: project)
.represent(closed_merge_request, serializer: 'sidebar')
)
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
preload_view_requirements
......@@ -45,6 +41,33 @@ describe 'projects/merge_requests/show.html.haml' do
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
end
describe 'merge request assignee sidebar' do
context 'when assignee is allowed to merge' do
it 'does not show a warning icon' do
closed_merge_request.update(assignee_id: user.id)
project.add_maintainer(user)
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
render
expect(rendered).not_to have_css('.cannot-be-merged')
end
end
context 'when assignee is not allowed to merge' do
it 'shows a warning icon' do
reporter = create(:user)
project.add_reporter(reporter)
closed_merge_request.update(assignee_id: reporter.id)
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
render
expect(rendered).to have_css('.cannot-be-merged')
end
end
end
context 'when the merge request is closed' do
it 'shows the "Reopen" button' do
render
......@@ -80,4 +103,10 @@ describe 'projects/merge_requests/show.html.haml' do
expect(rendered).to have_css('a', visible: false, text: 'Close')
end
end
def serialize_issuable_sidebar(user, project, merge_request)
MergeRequestSerializer
.new(current_user: user, project: project)
.represent(closed_merge_request, serializer: 'sidebar')
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