Merge lp:~nigelbabu/launchpad/js-regression-849121 into lp:launchpad

Proposed by Nigel Babu
Status: Merged
Merged at revision: 13979
Proposed branch: lp:~nigelbabu/launchpad/js-regression-849121
Merge into: lp:launchpad
Diff against target: 92 lines (+56/-1)
2 files modified
lib/lp/app/javascript/lp-links.js (+3/-0)
lib/lp/app/javascript/tests/test_lp_links.js (+53/-1)
To merge this branch: bzr merge lp:~nigelbabu/launchpad/js-regression-849121
Reviewer Review Type Date Requested Status
William Grant (community) code Approve
Review via email: mp+75858@code.launchpad.net

Commit message

Fixes the lp-links edge case of having no branches or no bugs. Added more tests to catch the edge cases.

Description of the change

= Description =
Fixes the JavaScript edge case of having no branches or no bugs. Added more javascript tests to catch the edge cases.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/lp-links.js
  lib/lp/app/javascript/tests/test_lp_links.js

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Seems to work. Thanks.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/lp-links.js'
2--- lib/lp/app/javascript/lp-links.js 2011-09-15 19:10:53 +0000
3+++ lib/lp/app/javascript/lp-links.js 2011-09-17 16:09:23 +0000
4@@ -28,6 +28,9 @@
5 // We have a collection of valid and invalid links containing links of
6 // type link_type, so we need to remove the existing link_class,
7 // replace it with an invalid-link class, and set the link title.
8+ if(!Y.Lang.isValue(link_info[link_type])) {
9+ return;
10+ }
11 var invalid_links = link_info[link_type].invalid || {};
12 var valid_links = link_info[link_type].valid || {};
13
14
15=== modified file 'lib/lp/app/javascript/tests/test_lp_links.js'
16--- lib/lp/app/javascript/tests/test_lp_links.js 2011-09-15 15:34:13 +0000
17+++ lib/lp/app/javascript/tests/test_lp_links.js 2011-09-17 16:09:23 +0000
18@@ -8,7 +8,7 @@
19 var mock_io = new Y.lp.testing.mockio.MockIo();
20
21 suite.add(new Y.Test.Case({
22- name: 'test_bugs',
23+ name: 'test_bugs_branches',
24
25 setUp: function() {
26 links.check_valid_lp_links(mock_io);
27@@ -30,6 +30,41 @@
28 });
29 },
30
31+ test_bugs_branches: function () {
32+ var validbug = Y.one('#valid-bug');
33+ var invalidbug = Y.one('#invalid-bug');
34+ var validbranch = Y.one('#valid-branch');
35+ var invalidbranch = Y.one('#invalid-branch');
36+ Y.Assert.isTrue(validbug.hasClass('bug-link'));
37+ Y.Assert.isTrue(invalidbug.hasClass('invalid-link'));
38+ Y.Assert.areSame(
39+ 'jokosher exposes personal details in its actions portlet',
40+ validbug.get('title')
41+ );
42+ Y.Assert.isTrue(validbranch.hasClass('branch-short-link'));
43+ Y.Assert.isTrue(invalidbranch.hasClass('invalid-link'));
44+ }
45+ }));
46+
47+ suite.add(new Y.Test.Case({
48+ name: 'test_bugs',
49+
50+ setUp: function() {
51+ links.check_valid_lp_links(mock_io);
52+ var response = {
53+ "bug_links": {
54+ "valid": {
55+ "/bugs/14": [
56+ "jokosher exposes personal details ",
57+ "in its actions portlet"].join('')},
58+ "invalid": {
59+ "/bugs/200": "Bug 200 cannot be found"}}};
60+ mock_io.success({
61+ responseText: Y.JSON.stringify(response),
62+ responseHeaders: {'Content-type': 'application/json'}
63+ });
64+ },
65+
66 test_bugs: function () {
67 var validbug = Y.one('#valid-bug');
68 var invalidbug = Y.one('#invalid-bug');
69@@ -39,6 +74,23 @@
70 'jokosher exposes personal details in its actions portlet',
71 validbug.get('title')
72 );
73+ }
74+ }));
75+
76+ suite.add(new Y.Test.Case({
77+ name: 'test_bugs',
78+
79+ setUp: function() {
80+ links.check_valid_lp_links(mock_io);
81+ var response = {
82+ "branch_links": {
83+ "invalid": {
84+ "/+branch/invalid":
85+ "No such product: 'invalid'."}}};
86+ mock_io.success({
87+ responseText: Y.JSON.stringify(response),
88+ responseHeaders: {'Content-type': 'application/json'}
89+ });
90 },
91
92 test_branch: function () {