Commit 2addba2b authored by Phil Hughes's avatar Phil Hughes

Merge branch '271589-report-abuse-on-merged-mr' into 'master'

Remove "Report abuse" button from a merged Merge Request

See merge request gitlab-org/gitlab!46031
parents 7b798038 b8e87c7a
......@@ -41,7 +41,7 @@
- if can_reopen_merge_request
%li{ class: merge_request_button_visibility(@merge_request, false) }
= link_to 'Reopen', merge_request_path(@merge_request, merge_request: { state_event: :reopen }), method: :put, class: 'reopen-mr-link', title: 'Reopen merge request'
- unless current_user == @merge_request.author
- unless @merge_request.merged? || current_user == @merge_request.author
%li= link_to 'Report abuse', new_abuse_report_path(user_id: @merge_request.author.id, ref_url: merge_request_url(@merge_request))
- if can_update_merge_request
......
......@@ -21,5 +21,6 @@
- else
= render 'shared/issuable/close_reopen_report_toggle', issuable: issuable, warn_before_close: add_blocked_class
- else
= link_to _('Report abuse'), new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)),
class: 'd-none d-md-block btn btn-grouped btn-close-color', title: _('Report abuse')
- unless issuable.is_a?(MergeRequest) && issuable.merged?
= link_to _('Report abuse'), new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)),
class: 'd-none d-md-block btn btn-grouped btn-close-color', title: _('Report abuse')
---
title: Remove "Report abuse" button from a merged Merge Request
merge_request: 46031
author: Takuya Noguchi
type: fixed
......@@ -105,6 +105,7 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do
end
context 'on a merge request' do
let(:container) { find('.detail-page-header-actions') }
let(:project) { create(:project, :repository) }
let(:issuable) { create(:merge_request, source_project: project) }
......@@ -120,24 +121,47 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do
it_behaves_like 'an issuable close/reopen/report toggle'
context 'when the merge request is closed' do
let(:issuable) { create(:merge_request, :closed, source_project: project) }
it 'shows both the `Edit` and `Reopen` button' do
expect(container).to have_link('Edit')
expect(container).not_to have_button('Report abuse')
expect(container).not_to have_button('Close merge request')
expect(container).to have_link('Reopen merge request')
end
context 'when the merge request author is the current user' do
let(:issuable) { create(:merge_request, :closed, source_project: project, author: user) }
it 'shows both the `Edit` and `Reopen` button' do
expect(container).to have_link('Edit')
expect(container).not_to have_link('Report abuse')
expect(container).not_to have_selector('button.dropdown-toggle')
expect(container).not_to have_button('Close merge request')
expect(container).to have_link('Reopen merge request')
end
end
end
context 'when the merge request is merged' do
let(:issuable) { create(:merge_request, :merged, source_project: project) }
it 'shows only the `Report abuse` and `Edit` button' do
expect(page).to have_link('Report abuse')
expect(page).to have_link(exact_text: 'Edit')
expect(page).not_to have_button('Close merge request')
expect(page).not_to have_button('Reopen merge request')
it 'shows only the `Edit` button' do
expect(container).to have_link(exact_text: 'Edit')
expect(container).not_to have_link('Report abuse')
expect(container).not_to have_button('Close merge request')
expect(container).not_to have_button('Reopen merge request')
end
context 'when the merge request author is the current user' do
let(:issuable) { create(:merge_request, :merged, source_project: project, author: user) }
it 'shows only the `Edit` button' do
expect(page).to have_link('Report abuse')
expect(page).to have_link(exact_text: 'Edit')
expect(page).not_to have_button('Close merge request')
expect(page).not_to have_button('Reopen merge request')
expect(container).to have_link(exact_text: 'Edit')
expect(container).not_to have_link('Report abuse')
expect(container).not_to have_button('Close merge request')
expect(container).not_to have_button('Reopen merge request')
end
end
end
......@@ -154,10 +178,10 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do
end
it 'only shows a `Report abuse` button' do
expect(page).to have_link('Report abuse')
expect(page).not_to have_button('Close merge request')
expect(page).not_to have_button('Reopen merge request')
expect(page).not_to have_link(exact_text: 'Edit')
expect(container).to have_link('Report abuse')
expect(container).not_to have_button('Close merge request')
expect(container).not_to have_button('Reopen merge request')
expect(container).not_to have_link(exact_text: 'Edit')
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