##// END OF EJS Templates
pull-requests: fix deletion of comments and make the test actually test this !...
marcink -
r1978:455f23f1 default
parent child Browse files
Show More
@@ -1084,16 +1084,41 b' class TestPullrequestsControllerDelete(o'
1084 response.mustcontain(no=['Confirm to delete this pull request'])
1084 response.mustcontain(no=['Confirm to delete this pull request'])
1085
1085
1086 def test_delete_comment_returns_404_if_comment_does_not_exist(
1086 def test_delete_comment_returns_404_if_comment_does_not_exist(
1087 self, autologin_user, pr_util, user_admin):
1087 self, autologin_user, pr_util, user_admin, csrf_token, xhr_header):
1088
1088
1089 pull_request = pr_util.create_pull_request(
1089 pull_request = pr_util.create_pull_request(
1090 author=user_admin.username, enable_notifications=False)
1090 author=user_admin.username, enable_notifications=False)
1091
1091
1092 self.app.get(route_path(
1092 self.app.post(
1093 route_path(
1093 'pullrequest_comment_delete',
1094 'pullrequest_comment_delete',
1094 repo_name=pull_request.target_repo.scm_instance().name,
1095 repo_name=pull_request.target_repo.scm_instance().name,
1095 pull_request_id=pull_request.pull_request_id,
1096 pull_request_id=pull_request.pull_request_id,
1096 comment_id=1024404), status=404)
1097 comment_id=1024404),
1098 extra_environ=xhr_header,
1099 params={'csrf_token': csrf_token},
1100 status=404
1101 )
1102
1103 def test_delete_comment(
1104 self, autologin_user, pr_util, user_admin, csrf_token, xhr_header):
1105
1106 pull_request = pr_util.create_pull_request(
1107 author=user_admin.username, enable_notifications=False)
1108 comment = pr_util.create_comment()
1109 comment_id = comment.comment_id
1110
1111 response = self.app.post(
1112 route_path(
1113 'pullrequest_comment_delete',
1114 repo_name=pull_request.target_repo.scm_instance().name,
1115 pull_request_id=pull_request.pull_request_id,
1116 comment_id=comment_id),
1117 extra_environ=xhr_header,
1118 params={'csrf_token': csrf_token},
1119 status=200
1120 )
1121 assert response.body == 'true'
1097
1122
1098
1123
1099 def assert_pull_request_status(pull_request, expected_status):
1124 def assert_pull_request_status(pull_request, expected_status):
@@ -1142,9 +1142,8 b' class RepoPullRequestsView(RepoAppView, '
1142 route_name='pullrequest_comment_delete', request_method='POST',
1142 route_name='pullrequest_comment_delete', request_method='POST',
1143 renderer='json_ext')
1143 renderer='json_ext')
1144 def pull_request_comment_delete(self):
1144 def pull_request_comment_delete(self):
1145 commit_id = self.request.matchdict['commit_id']
1145 pull_request_id = self.request.matchdict['pull_request_id']
1146 comment_id = self.request.matchdict['comment_id']
1146 comment_id = self.request.matchdict['comment_id']
1147 pull_request_id = self.request.matchdict['pull_request_id']
1148
1147
1149 pull_request = PullRequest.get_or_404(pull_request_id)
1148 pull_request = PullRequest.get_or_404(pull_request_id)
1150 if pull_request.is_closed():
1149 if pull_request.is_closed():
General Comments 0
You need to be logged in to leave comments. Login now