Commit 8caad774 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Fix approve button showing closed merge requests

parent 02c15350
......@@ -65,7 +65,7 @@ export default {
};
},
showApproveButton() {
return this.userCanApprove && !this.userHasApproved;
return this.userCanApprove && !this.userHasApproved && this.mr.isOpen;
},
showSuggestedApprovers() {
return this.suggestedApprovers && this.suggestedApprovers.length;
......
......@@ -32,10 +32,11 @@ describe 'User approves a merge request', :js do
before do
project.add_developer(user2)
project.add_developer(user3)
visit(merge_request_path(merge_request))
end
it 'shows multiple approvers beyond the needed count' do
visit(merge_request_path(merge_request))
click_button('Approve')
wait_for_requests
......@@ -47,6 +48,19 @@ describe 'User approves a merge request', :js do
expect(all('.js-approver-list-member').count).to eq(3)
end
it "doesn't show the approve additionally when a merge request is closed" do
merge_request_closed = create(:merge_request, :closed, source_project: project, target_project: project)
create(:approval, merge_request: merge_request_closed, user: user)
sign_in(user2)
visit(merge_request_path(merge_request_closed))
wait_for_requests
expect(page).not_to have_button('Approve')
expect(page).not_to have_button('Approve additionally')
end
def sign_in_visit_merge_request(user)
sign_in(user)
visit(merge_request_path(merge_request))
......
......@@ -20,7 +20,9 @@ import ApprovalsBody from 'ee/vue_merge_request_widget/components/approvals/appr
`);
this.initialData = {
mr: {},
mr: {
isOpen: true,
},
service: {},
suggestedApprovers: [{ name: 'Approver 1' }],
userCanApprove: false,
......
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