Merge lp:~sinzui/launchpad/daily-build-form into lp:launchpad

Proposed by Curtis Hovey on 2012-05-15
Status: Merged
Merged at revision: 15253
Proposed branch: lp:~sinzui/launchpad/daily-build-form
Merge into: lp:launchpad
Diff against target: 33 lines (+12/-1)
2 files modified
lib/lp/code/javascript/requestbuild_overlay.js (+4/-1)
lib/lp/code/javascript/tests/test_requestbuild_overlay.js (+8/-0)
To merge this branch: bzr merge lp:~sinzui/launchpad/daily-build-form
Reviewer Review Type Date Requested Status
Richard Harding (community) code 2012-05-15 Approve on 2012-05-15
Review via email: mp+105884@code.launchpad.net

Commit Message

Hide the daily build form if it exists.

Description of the Change

Pre-implementation: no one

When visiting a recipe page such as
https://code.qastaging.launchpad.net/~sinzui/+recipe/pocket-lint-daily I
see an error:
    Uncaught TypeError: Cannot call method 'addClass' of null
The browser just executed.
    Y.one('#request-daily-build-form').addClass('unseen')

The request-daily-build-form form is only rendered when the link is
available. This regression was introduced when I replaced the noscript
with a call to hide the form.

--------------------------------------------------------------------

RULES

    * Do not call addClass() if the form was not rendered.

QA

    * Visit https://code.qastaging.launchpad.net/~sinzui/+recipe/pocket-lint-daily
    * Verify there is not a TypeError when the page loads

LINT

    lib/lp/code/javascript/requestbuild_overlay.js
    lib/lp/code/javascript/tests/test_requestbuild_overlay.js

TEST

    ./bin/test -vvc --layer=YUITest lp.code

IMPLEMENTATION

Check that there is a node befor adding a class.
    lib/lp/code/javascript/requestbuild_overlay.js
    lib/lp/code/javascript/tests/test_requestbuild_overlay.js

To post a comment you must log in.
Richard Harding (rharding) wrote :

Thanks, and appreciate the test to go with it there.

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/code/javascript/requestbuild_overlay.js'
2--- lib/lp/code/javascript/requestbuild_overlay.js 2012-04-27 23:34:27 +0000
3+++ lib/lp/code/javascript/requestbuild_overlay.js 2012-05-15 19:41:27 +0000
4@@ -59,7 +59,10 @@
5 }
6 Y.lp.code.requestbuild_overlay.connect_requestbuilds();
7 }
8- Y.one('#request-daily-build-form').addClass('unseen');
9+ var form = Y.one('#request-daily-build-form');
10+ if (form) {
11+ form.addClass('unseen');
12+ }
13 };
14
15
16
17=== modified file 'lib/lp/code/javascript/tests/test_requestbuild_overlay.js'
18--- lib/lp/code/javascript/tests/test_requestbuild_overlay.js 2012-04-27 23:39:20 +0000
19+++ lib/lp/code/javascript/tests/test_requestbuild_overlay.js 2012-05-15 19:41:27 +0000
20@@ -264,6 +264,14 @@
21 Y.one('#request-daily-build-form').hasClass('unseen'));
22 Y.Assert.isFalse(
23 Y.one('#request-daily-build').hasClass('unseen'));
24+ },
25+
26+ test_hookUpDailyBuildsSchedule_without_form: function() {
27+ var form = Y.one('#request-daily-build-form');
28+ form.get('parentNode').removeChild(form);
29+ module.hookUpDailyBuildsSchedule();
30+ Y.Assert.isFalse(
31+ Y.one('#request-daily-build').hasClass('unseen'));
32 }
33 }));
34