diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-09-20 16:41:15 +0200 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-10-02 16:17:55 +0200 |
commit | e2056f08f072805a132bf18879749e401d8ad620 (patch) | |
tree | b6f7011f7df982cb6c70d604beeef3c656250f7a /spec | |
parent | ba66e0cc9cc26df686ed47d926a3edcde497baa1 (diff) | |
download | gitlab-ce-e2056f08f072805a132bf18879749e401d8ad620.tar.gz |
Hides Close MR button on merged MR50161-hide-close-mr-button-when-merged
When a Merge request is merged, shows only the Report abuse menu item
in the dropdown menu instead of showing the close_reopen_report toggle
with an unusable Close button.
The Report abuse is still hidden when the author of the Merge request
is the current_user.
Hides the Reopen button on a closed and locked issue when the
issue.author is not the current_user
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/issues.rb | 4 | ||||
-rw-r--r-- | spec/features/issuables/close_reopen_report_toggle_spec.rb | 40 | ||||
-rw-r--r-- | spec/policies/issue_policy_spec.rb | 2 |
3 files changed, 45 insertions, 1 deletions
diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 4d4f74e101e..ab27fee33dc 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -13,6 +13,10 @@ FactoryBot.define do state :opened end + trait :locked do + discussion_locked true + end + trait :closed do state :closed closed_at { Time.now } diff --git a/spec/features/issuables/close_reopen_report_toggle_spec.rb b/spec/features/issuables/close_reopen_report_toggle_spec.rb index de6f5fe1560..26c44baeb21 100644 --- a/spec/features/issuables/close_reopen_report_toggle_spec.rb +++ b/spec/features/issuables/close_reopen_report_toggle_spec.rb @@ -56,6 +56,24 @@ describe 'Issuables Close/Reopen/Report toggle' do end it_behaves_like 'an issuable close/reopen/report toggle' + + context 'when the issue is closed and locked' do + let(:issuable) { create(:issue, :closed, :locked, project: project) } + + it 'hides the reopen button' do + expect(page).not_to have_link('Reopen issue') + end + + context 'when the issue author is the current user' do + before do + issuable.update(author: user) + end + + it 'hides the reopen button' do + expect(page).not_to have_link('Reopen issue') + end + end + end end context 'when user doesnt have permission to update' do @@ -93,6 +111,28 @@ describe 'Issuables Close/Reopen/Report toggle' do end it_behaves_like 'an issuable close/reopen/report toggle' + + 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('Edit') + expect(page).not_to have_link('Close merge request') + expect(page).not_to have_link('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('Edit') + expect(page).not_to have_link('Report abuse') + expect(page).not_to have_link('Close merge request') + expect(page).not_to have_link('Reopen merge request') + end + end + end end context 'when user doesnt have permission to update' do diff --git a/spec/policies/issue_policy_spec.rb b/spec/policies/issue_policy_spec.rb index 93e85b3a6fa..008d118b557 100644 --- a/spec/policies/issue_policy_spec.rb +++ b/spec/policies/issue_policy_spec.rb @@ -112,7 +112,7 @@ describe IssuePolicy do let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project, assignees: [assignee], author: author) } let(:issue_no_assignee) { create(:issue, project: project) } - let(:issue_locked) { create(:issue, project: project, discussion_locked: true, author: author, assignees: [assignee]) } + let(:issue_locked) { create(:issue, :locked, project: project, author: author, assignees: [assignee]) } before do project.add_guest(guest) |