Show More
@@ -420,6 +420,27 b' class TestPullrequestsView(object):' | |||
|
420 | 420 | assert pull_request.title == 'New title' |
|
421 | 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 | 444 | def test_edit_title_description_closed(self, pr_util, csrf_token): |
|
424 | 445 | pull_request = pr_util.create_pull_request() |
|
425 | 446 | pull_request_id = pull_request.pull_request_id |
@@ -4220,6 +4220,12 b' class _PullRequestBase(BaseModel):' | |||
|
4220 | 4220 | return True |
|
4221 | 4221 | return False |
|
4222 | 4222 | |
|
4223 | @property | |
|
4224 | def title_safe(self): | |
|
4225 | return self.title\ | |
|
4226 | .replace('{', '{{')\ | |
|
4227 | .replace('}', '}}') | |
|
4228 | ||
|
4223 | 4229 | @hybrid_property |
|
4224 | 4230 | def description_safe(self): |
|
4225 | 4231 | from rhodecode.lib import helpers as h |
@@ -1462,7 +1462,6 b' var CommentsController = function() {' | |||
|
1462 | 1462 | |
|
1463 | 1463 | var comment = $('#comment-'+commentId); |
|
1464 | 1464 | var commentData = comment.data(); |
|
1465 | console.log(commentData); | |
|
1466 | 1465 | |
|
1467 | 1466 | if (commentData.commentInline) { |
|
1468 | 1467 | var f_path = commentData.commentFPath; |
@@ -14,7 +14,7 b' data = {' | |||
|
14 | 14 | 'comment_type': comment_type, |
|
15 | 15 | 'comment_id': comment_id, |
|
16 | 16 | |
|
17 | 'pr_title': pull_request.title, | |
|
17 | 'pr_title': pull_request.title_safe, | |
|
18 | 18 | 'pr_id': pull_request.pull_request_id, |
|
19 | 19 | 'mention_prefix': '[mention] ' if mention else '', |
|
20 | 20 | } |
@@ -31,7 +31,6 b' else:' | |||
|
31 | 31 | _('{mention_prefix}{user} left a {comment_type} on pull request !{pr_id}: "{pr_title}"').format(**data) |
|
32 | 32 | %> |
|
33 | 33 | |
|
34 | ||
|
35 | 34 | ${subject_template.format(**data) |n} |
|
36 | 35 | </%def> |
|
37 | 36 | |
@@ -47,7 +46,7 b' data = {' | |||
|
47 | 46 | 'comment_type': comment_type, |
|
48 | 47 | 'comment_id': comment_id, |
|
49 | 48 | |
|
50 | 'pr_title': pull_request.title, | |
|
49 | 'pr_title': pull_request.title_safe, | |
|
51 | 50 | 'pr_id': pull_request.pull_request_id, |
|
52 | 51 | 'source_ref_type': pull_request.source_ref_parts.type, |
|
53 | 52 | 'source_ref_name': pull_request.source_ref_parts.name, |
@@ -99,7 +98,7 b' data = {' | |||
|
99 | 98 | 'comment_id': comment_id, |
|
100 | 99 | 'renderer_type': renderer_type or 'plain', |
|
101 | 100 | |
|
102 | 'pr_title': pull_request.title, | |
|
101 | 'pr_title': pull_request.title_safe, | |
|
103 | 102 | 'pr_id': pull_request.pull_request_id, |
|
104 | 103 | 'status': status_change, |
|
105 | 104 | 'source_ref_type': pull_request.source_ref_parts.type, |
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | data = { |
|
9 | 9 | 'user': '@'+h.person(user), |
|
10 | 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 | 14 | if user_role == 'observer': |
@@ -26,7 +26,7 b' else:' | |||
|
26 | 26 | data = { |
|
27 | 27 | 'user': h.person(user), |
|
28 | 28 | 'pr_id': pull_request.pull_request_id, |
|
29 | 'pr_title': pull_request.title, | |
|
29 | 'pr_title': pull_request.title_safe, | |
|
30 | 30 | 'source_ref_type': pull_request.source_ref_parts.type, |
|
31 | 31 | 'source_ref_name': pull_request.source_ref_parts.name, |
|
32 | 32 | 'target_ref_type': pull_request.target_ref_parts.type, |
@@ -66,7 +66,7 b' data = {' | |||
|
66 | 66 | data = { |
|
67 | 67 | 'user': h.person(user), |
|
68 | 68 | 'pr_id': pull_request.pull_request_id, |
|
69 | 'pr_title': pull_request.title, | |
|
69 | 'pr_title': pull_request.title_safe, | |
|
70 | 70 | 'source_ref_type': pull_request.source_ref_parts.type, |
|
71 | 71 | 'source_ref_name': pull_request.source_ref_parts.name, |
|
72 | 72 | 'target_ref_type': pull_request.target_ref_parts.type, |
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | data = { |
|
9 | 9 | 'updating_user': '@'+h.person(updating_user), |
|
10 | 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 | 14 | subject_template = email_pr_update_subject_template or _('{updating_user} updated pull request. !{pr_id}: "{pr_title}"') |
@@ -23,7 +23,7 b' subject_template = email_pr_update_subje' | |||
|
23 | 23 | data = { |
|
24 | 24 | 'updating_user': h.person(updating_user), |
|
25 | 25 | 'pr_id': pull_request.pull_request_id, |
|
26 | 'pr_title': pull_request.title, | |
|
26 | 'pr_title': pull_request.title_safe, | |
|
27 | 27 | 'source_ref_type': pull_request.source_ref_parts.type, |
|
28 | 28 | 'source_ref_name': pull_request.source_ref_parts.name, |
|
29 | 29 | 'target_ref_type': pull_request.target_ref_parts.type, |
@@ -74,7 +74,7 b' data = {' | |||
|
74 | 74 | data = { |
|
75 | 75 | 'updating_user': h.person(updating_user), |
|
76 | 76 | 'pr_id': pull_request.pull_request_id, |
|
77 | 'pr_title': pull_request.title, | |
|
77 | 'pr_title': pull_request.title_safe, | |
|
78 | 78 | 'source_ref_type': pull_request.source_ref_parts.type, |
|
79 | 79 | 'source_ref_name': pull_request.source_ref_parts.name, |
|
80 | 80 | 'target_ref_type': pull_request.target_ref_parts.type, |
@@ -27,6 +27,16 b' from rhodecode.model.db import User, Pul' | |||
|
27 | 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 | 40 | def test_get_template_obj(app, request_stub): |
|
31 | 41 | template = EmailNotificationModel().get_renderer( |
|
32 | 42 | EmailNotificationModel.TYPE_TEST, request_stub) |
@@ -53,14 +63,10 b' def test_render_email(app, http_host_onl' | |||
|
53 | 63 | |
|
54 | 64 | |
|
55 | 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 | 67 | ref = collections.namedtuple( |
|
58 | 68 | 'Ref', 'name, type')('fxies123', 'book') |
|
59 | ||
|
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 | ||
|
69 | pr = pr(ref) | |
|
64 | 70 | source_repo = target_repo = collections.namedtuple( |
|
65 | 71 | 'Repo', 'type, repo_name')('hg', 'pull_request_1') |
|
66 | 72 | |
@@ -89,13 +95,11 b' def test_render_pr_email(app, user_admin' | |||
|
89 | 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 | 99 | ref = collections.namedtuple( |
|
94 | 100 | 'Ref', 'name, type')('fxies123', 'book') |
|
95 | 101 | |
|
96 | pr = collections.namedtuple('PullRequest', | |
|
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') | |
|
102 | pr = pr(ref) | |
|
99 | 103 | |
|
100 | 104 | source_repo = target_repo = collections.namedtuple( |
|
101 | 105 | 'Repo', 'type, repo_name')('hg', 'pull_request_1') |
@@ -150,13 +154,11 b' def test_render_pr_update_email(app, use' | |||
|
150 | 154 | EmailNotificationModel.TYPE_COMMIT_COMMENT, |
|
151 | 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 | 158 | ref = collections.namedtuple( |
|
155 | 159 | 'Ref', 'name, type')('fxies123', 'book') |
|
156 | 160 | |
|
157 | pr = collections.namedtuple('PullRequest', | |
|
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') | |
|
161 | pr = pr(ref) | |
|
160 | 162 | |
|
161 | 163 | source_repo = target_repo = collections.namedtuple( |
|
162 | 164 | 'Repo', 'type, repo_name')('hg', 'pull_request_1') |
General Comments 0
You need to be logged in to leave comments.
Login now