##// END OF EJS Templates
pull-requests: fixed a case when template marker was used in description field....
milka -
r4631:21211d2f stable
parent child
Show More
@@ -420,6 +420,27 class TestPullrequestsView(object):
420 assert pull_request.title == 'New title'
420 assert pull_request.title == 'New title'
421 assert pull_request.description == 'New description'
421 assert pull_request.description == 'New description'
422
422
423 def test_edit_title_description(self, pr_util, csrf_token):
424 pull_request = pr_util.create_pull_request()
425 pull_request_id = pull_request.pull_request_id
426
427 response = self.app.post(
428 route_path('pullrequest_update',
429 repo_name=pull_request.target_repo.repo_name,
430 pull_request_id=pull_request_id),
431 params={
432 'edit_pull_request': 'true',
433 'title': 'New title {} {2} {foo}',
434 'description': 'New description',
435 'csrf_token': csrf_token})
436
437 assert_session_flash(
438 response, u'Pull request title & description updated.',
439 category='success')
440
441 pull_request = PullRequest.get(pull_request_id)
442 assert pull_request.title_safe == 'New title {{}} {{2}} {{foo}}'
443
423 def test_edit_title_description_closed(self, pr_util, csrf_token):
444 def test_edit_title_description_closed(self, pr_util, csrf_token):
424 pull_request = pr_util.create_pull_request()
445 pull_request = pr_util.create_pull_request()
425 pull_request_id = pull_request.pull_request_id
446 pull_request_id = pull_request.pull_request_id
@@ -4220,6 +4220,12 class _PullRequestBase(BaseModel):
4220 return True
4220 return True
4221 return False
4221 return False
4222
4222
4223 @property
4224 def title_safe(self):
4225 return self.title\
4226 .replace('{', '{{')\
4227 .replace('}', '}}')
4228
4223 @hybrid_property
4229 @hybrid_property
4224 def description_safe(self):
4230 def description_safe(self):
4225 from rhodecode.lib import helpers as h
4231 from rhodecode.lib import helpers as h
@@ -1462,7 +1462,6 var CommentsController = function() {
1462
1462
1463 var comment = $('#comment-'+commentId);
1463 var comment = $('#comment-'+commentId);
1464 var commentData = comment.data();
1464 var commentData = comment.data();
1465 console.log(commentData);
1466
1465
1467 if (commentData.commentInline) {
1466 if (commentData.commentInline) {
1468 var f_path = commentData.commentFPath;
1467 var f_path = commentData.commentFPath;
@@ -14,7 +14,7 data = {
14 'comment_type': comment_type,
14 'comment_type': comment_type,
15 'comment_id': comment_id,
15 'comment_id': comment_id,
16
16
17 'pr_title': pull_request.title,
17 'pr_title': pull_request.title_safe,
18 'pr_id': pull_request.pull_request_id,
18 'pr_id': pull_request.pull_request_id,
19 'mention_prefix': '[mention] ' if mention else '',
19 'mention_prefix': '[mention] ' if mention else '',
20 }
20 }
@@ -31,7 +31,6 else:
31 _('{mention_prefix}{user} left a {comment_type} on pull request !{pr_id}: "{pr_title}"').format(**data)
31 _('{mention_prefix}{user} left a {comment_type} on pull request !{pr_id}: "{pr_title}"').format(**data)
32 %>
32 %>
33
33
34
35 ${subject_template.format(**data) |n}
34 ${subject_template.format(**data) |n}
36 </%def>
35 </%def>
37
36
@@ -47,7 +46,7 data = {
47 'comment_type': comment_type,
46 'comment_type': comment_type,
48 'comment_id': comment_id,
47 'comment_id': comment_id,
49
48
50 'pr_title': pull_request.title,
49 'pr_title': pull_request.title_safe,
51 'pr_id': pull_request.pull_request_id,
50 'pr_id': pull_request.pull_request_id,
52 'source_ref_type': pull_request.source_ref_parts.type,
51 'source_ref_type': pull_request.source_ref_parts.type,
53 'source_ref_name': pull_request.source_ref_parts.name,
52 'source_ref_name': pull_request.source_ref_parts.name,
@@ -99,7 +98,7 data = {
99 'comment_id': comment_id,
98 'comment_id': comment_id,
100 'renderer_type': renderer_type or 'plain',
99 'renderer_type': renderer_type or 'plain',
101
100
102 'pr_title': pull_request.title,
101 'pr_title': pull_request.title_safe,
103 'pr_id': pull_request.pull_request_id,
102 'pr_id': pull_request.pull_request_id,
104 'status': status_change,
103 'status': status_change,
105 'source_ref_type': pull_request.source_ref_parts.type,
104 'source_ref_type': pull_request.source_ref_parts.type,
@@ -8,7 +8,7
8 data = {
8 data = {
9 'user': '@'+h.person(user),
9 'user': '@'+h.person(user),
10 'pr_id': pull_request.pull_request_id,
10 'pr_id': pull_request.pull_request_id,
11 'pr_title': pull_request.title,
11 'pr_title': pull_request.title_safe,
12 }
12 }
13
13
14 if user_role == 'observer':
14 if user_role == 'observer':
@@ -26,7 +26,7 else:
26 data = {
26 data = {
27 'user': h.person(user),
27 'user': h.person(user),
28 'pr_id': pull_request.pull_request_id,
28 'pr_id': pull_request.pull_request_id,
29 'pr_title': pull_request.title,
29 'pr_title': pull_request.title_safe,
30 'source_ref_type': pull_request.source_ref_parts.type,
30 'source_ref_type': pull_request.source_ref_parts.type,
31 'source_ref_name': pull_request.source_ref_parts.name,
31 'source_ref_name': pull_request.source_ref_parts.name,
32 'target_ref_type': pull_request.target_ref_parts.type,
32 'target_ref_type': pull_request.target_ref_parts.type,
@@ -66,7 +66,7 data = {
66 data = {
66 data = {
67 'user': h.person(user),
67 'user': h.person(user),
68 'pr_id': pull_request.pull_request_id,
68 'pr_id': pull_request.pull_request_id,
69 'pr_title': pull_request.title,
69 'pr_title': pull_request.title_safe,
70 'source_ref_type': pull_request.source_ref_parts.type,
70 'source_ref_type': pull_request.source_ref_parts.type,
71 'source_ref_name': pull_request.source_ref_parts.name,
71 'source_ref_name': pull_request.source_ref_parts.name,
72 'target_ref_type': pull_request.target_ref_parts.type,
72 'target_ref_type': pull_request.target_ref_parts.type,
@@ -8,7 +8,7
8 data = {
8 data = {
9 'updating_user': '@'+h.person(updating_user),
9 'updating_user': '@'+h.person(updating_user),
10 'pr_id': pull_request.pull_request_id,
10 'pr_id': pull_request.pull_request_id,
11 'pr_title': pull_request.title,
11 'pr_title': pull_request.title_safe,
12 }
12 }
13
13
14 subject_template = email_pr_update_subject_template or _('{updating_user} updated pull request. !{pr_id}: "{pr_title}"')
14 subject_template = email_pr_update_subject_template or _('{updating_user} updated pull request. !{pr_id}: "{pr_title}"')
@@ -23,7 +23,7 subject_template = email_pr_update_subje
23 data = {
23 data = {
24 'updating_user': h.person(updating_user),
24 'updating_user': h.person(updating_user),
25 'pr_id': pull_request.pull_request_id,
25 'pr_id': pull_request.pull_request_id,
26 'pr_title': pull_request.title,
26 'pr_title': pull_request.title_safe,
27 'source_ref_type': pull_request.source_ref_parts.type,
27 'source_ref_type': pull_request.source_ref_parts.type,
28 'source_ref_name': pull_request.source_ref_parts.name,
28 'source_ref_name': pull_request.source_ref_parts.name,
29 'target_ref_type': pull_request.target_ref_parts.type,
29 'target_ref_type': pull_request.target_ref_parts.type,
@@ -74,7 +74,7 data = {
74 data = {
74 data = {
75 'updating_user': h.person(updating_user),
75 'updating_user': h.person(updating_user),
76 'pr_id': pull_request.pull_request_id,
76 'pr_id': pull_request.pull_request_id,
77 'pr_title': pull_request.title,
77 'pr_title': pull_request.title_safe,
78 'source_ref_type': pull_request.source_ref_parts.type,
78 'source_ref_type': pull_request.source_ref_parts.type,
79 'source_ref_name': pull_request.source_ref_parts.name,
79 'source_ref_name': pull_request.source_ref_parts.name,
80 'target_ref_type': pull_request.target_ref_parts.type,
80 'target_ref_type': pull_request.target_ref_parts.type,
@@ -27,6 +27,16 from rhodecode.model.db import User, Pul
27 from rhodecode.model.notification import EmailNotificationModel
27 from rhodecode.model.notification import EmailNotificationModel
28
28
29
29
30 @pytest.fixture()
31 def pr():
32 def factory(ref):
33 return collections.namedtuple(
34 'PullRequest',
35 'pull_request_id, title, title_safe, description, source_ref_parts, source_ref_name, target_ref_parts, target_ref_name')\
36 (200, 'Example Pull Request', 'Example Pull Request', 'Desc of PR', ref, 'bookmark', ref, 'Branch')
37 return factory
38
39
30 def test_get_template_obj(app, request_stub):
40 def test_get_template_obj(app, request_stub):
31 template = EmailNotificationModel().get_renderer(
41 template = EmailNotificationModel().get_renderer(
32 EmailNotificationModel.TYPE_TEST, request_stub)
42 EmailNotificationModel.TYPE_TEST, request_stub)
@@ -53,14 +63,10 def test_render_email(app, http_host_onl
53
63
54
64
55 @pytest.mark.parametrize('role', PullRequestReviewers.ROLES)
65 @pytest.mark.parametrize('role', PullRequestReviewers.ROLES)
56 def test_render_pr_email(app, user_admin, role):
66 def test_render_pr_email(app, user_admin, role, pr):
57 ref = collections.namedtuple(
67 ref = collections.namedtuple(
58 'Ref', 'name, type')('fxies123', 'book')
68 'Ref', 'name, type')('fxies123', 'book')
59
69 pr = pr(ref)
60 pr = collections.namedtuple('PullRequest',
61 'pull_request_id, title, description, source_ref_parts, source_ref_name, target_ref_parts, target_ref_name')(
62 200, 'Example Pull Request', 'Desc of PR', ref, 'bookmark', ref, 'Branch')
63
64 source_repo = target_repo = collections.namedtuple(
70 source_repo = target_repo = collections.namedtuple(
65 'Repo', 'type, repo_name')('hg', 'pull_request_1')
71 'Repo', 'type, repo_name')('hg', 'pull_request_1')
66
72
@@ -89,13 +95,11 def test_render_pr_email(app, user_admin
89 assert subject == '@test_admin (RhodeCode Admin) added you as observer to pull request. !200: "Example Pull Request"'
95 assert subject == '@test_admin (RhodeCode Admin) added you as observer to pull request. !200: "Example Pull Request"'
90
96
91
97
92 def test_render_pr_update_email(app, user_admin):
98 def test_render_pr_update_email(app, user_admin, pr):
93 ref = collections.namedtuple(
99 ref = collections.namedtuple(
94 'Ref', 'name, type')('fxies123', 'book')
100 'Ref', 'name, type')('fxies123', 'book')
95
101
96 pr = collections.namedtuple('PullRequest',
102 pr = pr(ref)
97 'pull_request_id, title, description, source_ref_parts, source_ref_name, target_ref_parts, target_ref_name')(
98 200, 'Example Pull Request', 'Desc of PR', ref, 'bookmark', ref, 'Branch')
99
103
100 source_repo = target_repo = collections.namedtuple(
104 source_repo = target_repo = collections.namedtuple(
101 'Repo', 'type, repo_name')('hg', 'pull_request_1')
105 'Repo', 'type, repo_name')('hg', 'pull_request_1')
@@ -150,13 +154,11 def test_render_pr_update_email(app, use
150 EmailNotificationModel.TYPE_COMMIT_COMMENT,
154 EmailNotificationModel.TYPE_COMMIT_COMMENT,
151 EmailNotificationModel.TYPE_PULL_REQUEST_COMMENT
155 EmailNotificationModel.TYPE_PULL_REQUEST_COMMENT
152 ])
156 ])
153 def test_render_comment_subject_no_newlines(app, mention, email_type):
157 def test_render_comment_subject_no_newlines(app, mention, email_type, pr):
154 ref = collections.namedtuple(
158 ref = collections.namedtuple(
155 'Ref', 'name, type')('fxies123', 'book')
159 'Ref', 'name, type')('fxies123', 'book')
156
160
157 pr = collections.namedtuple('PullRequest',
161 pr = pr(ref)
158 'pull_request_id, title, description, source_ref_parts, source_ref_name, target_ref_parts, target_ref_name')(
159 200, 'Example Pull Request', 'Desc of PR', ref, 'bookmark', ref, 'Branch')
160
162
161 source_repo = target_repo = collections.namedtuple(
163 source_repo = target_repo = collections.namedtuple(
162 'Repo', 'type, repo_name')('hg', 'pull_request_1')
164 'Repo', 'type, repo_name')('hg', 'pull_request_1')
General Comments 0
You need to be logged in to leave comments. Login now