Commit dfdad8ab authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-approvals-button' into 'master'

Fix "Remove your approval" button visibility for merged MRs

Closes #2439

See merge request !1936
parents e12582ec 237f16da
...@@ -46,7 +46,8 @@ export default { ...@@ -46,7 +46,8 @@ export default {
}, },
computed: { computed: {
showUnapproveButton() { showUnapproveButton() {
return this.userHasApproved && !this.userCanApprove; const isMerged = this.mr.state === 'merged';
return this.userHasApproved && !this.userCanApprove && !isMerged;
}, },
}, },
methods: { methods: {
......
...@@ -21,6 +21,10 @@ import ApprovalsFooter from '~/vue_merge_request_widget/ee/components/approvals/ ...@@ -21,6 +21,10 @@ import ApprovalsFooter from '~/vue_merge_request_widget/ee/components/approvals/
`); `);
this.initialData = { this.initialData = {
mr: {
state: 'readyToMerge',
},
service: {},
userCanApprove: false, userCanApprove: false,
userHasApproved: true, userHasApproved: true,
approvedBy: [], approvedBy: [],
...@@ -53,7 +57,9 @@ import ApprovalsFooter from '~/vue_merge_request_widget/ee/components/approvals/ ...@@ -53,7 +57,9 @@ import ApprovalsFooter from '~/vue_merge_request_widget/ee/components/approvals/
describe('Computed properties', function () { describe('Computed properties', function () {
it('should correctly set showUnapproveButton when the user can unapprove', function () { it('should correctly set showUnapproveButton when the user can unapprove', function () {
expect(this.approvalsFooter.showUnapproveButton).toBe(true); expect(this.approvalsFooter.showUnapproveButton).toBeTruthy();
this.approvalsFooter.mr.state = 'merged';
expect(this.approvalsFooter.showUnapproveButton).toBeFalsy();
}); });
it('should correctly set showUnapproveButton when the user can not unapprove', function (done) { it('should correctly set showUnapproveButton when the user can not unapprove', function (done) {
......
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