MR "Comment & close" should close and comment using AJAX, and only reload the page once both have succeeded
The "Comment & close merge request" feature works only because in a production environment, the PUT to close is a lot slower than the POST to comment which is using over AJAX, meaning the comment will usually succeed before the close does. If the close were to succeed before the comment, the comment may not even make it all, since the AJAX request would be canceled.
There is, however, nothing in the code ensuring this comment -> close order. The PUT to close is handled by rails-js when this button is clicked, because of the merge_request_path(@merge_request, merge_request: { state_event: :close }), method: :put bit, and this is a simple request that will result in a reload of the whole page. The POST to comment is handled by this JS, which uses AJAX and doesn't result in a reload.
With "Comment & close issue" on issues, this problem doesn't exist, because here, JS is responsible for both commenting and closing: http://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/issue.js#L31. Both happen over AJAX, so the order doesn't really matter.
To make sure both the POST to comment and the PUT to close succeed before the page is reload, we should handle both in JS and using AJAX, and only trigger the reload once both have succeeded.