Commit d403d7ac authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Robert Speicher

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

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