Merge lp:~wallyworld/launchpad/update-dupe-comment-597971 into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 15762
Proposed branch: lp:~wallyworld/launchpad/update-dupe-comment-597971
Merge into: lp:launchpad
Diff against target: 81 lines (+24/-14)
3 files modified
lib/lp/bugs/javascript/duplicates.js (+15/-13)
lib/lp/bugs/javascript/tests/test_duplicates.html (+2/-0)
lib/lp/bugs/javascript/tests/test_duplicates.js (+7/-1)
To merge this branch: bzr merge lp:~wallyworld/launchpad/update-dupe-comment-597971
Reviewer Review Type Date Requested Status
Ian Booth (community) Approve
Review via email: mp+118649@code.launchpad.net

Commit message

Ensure the bug dupe warning comment is always updated correctly.

Description of the change

== Implementation ==

A quick fix to ensure the bug dupe warning comment is updated correctly.

== Tests ==

Update an existing yui test

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/javascript/duplicates.js
  lib/lp/bugs/javascript/tests/test_duplicates.js

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :

Trivial change, self review

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/javascript/duplicates.js'
2--- lib/lp/bugs/javascript/duplicates.js 2012-08-06 11:19:31 +0000
3+++ lib/lp/bugs/javascript/duplicates.js 2012-08-07 23:15:28 +0000
4@@ -280,23 +280,25 @@
5 * @private
6 */
7 _show_comment_on_duplicate_warning: function(bug_id, title) {
8+ var dupe_link = Y.Lang.substitute(
9+ '<a title="{title}" id="duplicate-of-warning-link" ' +
10+ 'href="/bugs/{id}" style="margin-right: 4px">bug #{id}.</a>',
11+ {id: bug_id, title: title});
12+ var new_duplicate_warning = Y.Node.create(
13+ ['<div class="block-sprite large-warning"',
14+ 'id="warning-comment-on-duplicate">',
15+ 'Remember, this bug report is a duplicate of ',
16+ dupe_link,
17+ '<br>Comment here only if you think the duplicate status ',
18+ 'is wrong.',
19+ '</div>'].join(''));
20 var duplicate_warning = Y.one('#warning-comment-on-duplicate');
21 if (!Y.Lang.isValue(duplicate_warning)) {
22 var container = Y.one('#add-comment-form');
23 var first_node = container.get('firstChild');
24- var dupe_link = Y.Lang.substitute(
25- '<a title="{title}" id="duplicate-of-warning-link" ' +
26- 'href="/bugs/{id}" style="margin-right: 4px">bug #{id}.</a>',
27- {id: bug_id, title: title});
28- duplicate_warning = Y.Node.create(
29- ['<div class="block-sprite large-warning"',
30- 'id="warning-comment-on-duplicate">',
31- 'Remember, this bug report is a duplicate of ',
32- dupe_link,
33- '<br>Comment here only if you think the duplicate status ',
34- 'is wrong.',
35- '</div>'].join(''));
36- container.insertBefore(duplicate_warning, first_node);
37+ container.insertBefore(new_duplicate_warning, first_node);
38+ } else {
39+ duplicate_warning.replace(new_duplicate_warning);
40 }
41 },
42
43
44=== modified file 'lib/lp/bugs/javascript/tests/test_duplicates.html'
45--- lib/lp/bugs/javascript/tests/test_duplicates.html 2012-08-03 12:47:11 +0000
46+++ lib/lp/bugs/javascript/tests/test_duplicates.html 2012-08-07 23:15:28 +0000
47@@ -74,6 +74,7 @@
48 </li>
49 </ul></div>
50 <div id="duplicate-form-container"></div>
51+ <div id="warning-comment-on-duplicate"></div>
52 <div id="add-comment-form"></div>
53 <div id="portlet-duplicates"></div>
54 </script>
55@@ -92,6 +93,7 @@
56 </li>
57 </ul></div>
58 <div id="duplicate-form-container"></div>
59+ <div id="warning-comment-on-duplicate"></div>
60 <div id="add-comment-form"></div>
61 </script>
62 </body>
63
64=== modified file 'lib/lp/bugs/javascript/tests/test_duplicates.js'
65--- lib/lp/bugs/javascript/tests/test_duplicates.js 2012-08-06 02:54:11 +0000
66+++ lib/lp/bugs/javascript/tests/test_duplicates.js 2012-08-07 23:15:28 +0000
67@@ -238,7 +238,13 @@
68 // Test the Change Duplicate link.
69 Y.Assert.isNotNull(Y.one('#mark-duplicate-text a'));
70 // Test the duplicate warning message.
71- Y.Assert.isNotNull(Y.one('#warning-comment-on-duplicate'));
72+ var dupe_warning = Y.one('#warning-comment-on-duplicate');
73+ Y.Assert.isNotNull(dupe_warning);
74+ Y.Assert.areEqual(
75+ 'Remember, this bug report is a duplicate of bug #3.' +
76+ 'Comment here only if you think the duplicate status ' +
77+ 'is wrong.',
78+ dupe_warning.get('text').trim());
79 // Any previously listed duplicates are removed.
80 Y.Assert.isNull(Y.one('#portlet-duplicates'));
81 },