Merge lp:~gmb/launchpad/subscribe-using-api-bug-697619 into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 12170
Proposed branch: lp:~gmb/launchpad/subscribe-using-api-bug-697619
Merge into: lp:launchpad
Diff against target: 58 lines (+30/-1)
2 files modified
lib/lp/bugs/javascript/bug_subscription_widget.js (+5/-0)
lib/lp/bugs/javascript/tests/test_bug_subscription_widget.js (+25/-1)
To merge this branch: bzr merge lp:~gmb/launchpad/subscribe-using-api-bug-697619
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+45353@code.launchpad.net

Commit message

[r=allenap][ui=none][bug=697619]

Description of the change

This branch fixes bug 697619 by making the new subscribe widget fire a
subscriptionwizard:save event when its form is submitted. In a
subsequent branch we'll use this event to hook the new widget up to the
existing subscription functionality.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Nice, I'm learning stuff :)

[1]

+ var submit_button =

Trailing whitespace.

[2]

+ Assert.isTrue(subscriptionwizard_save_fired);

Is it worth putting this after the call to show_wizard()? If the
subscriptionwizard:ready event is, say, renamed or removed, the
handler will never be fired, and the assertion never made.

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

[3]

- fetchCSS: false
+ fetchCSS: true,

Btw, what does this do?

Revision history for this message
Graham Binns (gmb) wrote :

> Nice, I'm learning stuff :)
>
>
> [1]
>
> + var submit_button =
>
> Trailing whitespace.
>

Arse. Fixed.

>
> [2]
>
> + Assert.isTrue(subscriptionwizard_save_fired);
>
> Is it worth putting this after the call to show_wizard()? If the
> subscriptionwizard:ready event is, say, renamed or removed, the
> handler will never be fired, and the assertion never made.

You're right. I originally moved it because I thought that asynchronicity was causing me problems. I've moved it back.

Revision history for this message
Graham Binns (gmb) wrote :

> [3]
>
> - fetchCSS: false
> + fetchCSS: true,
>
> Btw, what does this do?

It makes the CSS for the test page Not Suck. It shouldn't be committed though (and I've removed it) because it causes CSS to be fetched from elsewhere, and IIRC that will cause problems with the test runner.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/javascript/bug_subscription_widget.js'
2--- lib/lp/bugs/javascript/bug_subscription_widget.js 2010-12-14 10:42:45 +0000
3+++ lib/lp/bugs/javascript/bug_subscription_widget.js 2011-01-06 13:22:30 +0000
4@@ -39,6 +39,11 @@
5 steps: wizard_steps
6 });
7 namespace.subscription_wizard.render('#subscribe-wizard');
8+ namespace.subscription_wizard.form_node.on(
9+ 'submit', Y.bind(function(e) {
10+ e.preventDefault();
11+ Y.fire('subscriptionwizard:save');
12+ }));
13 Y.fire('subscriptionwizard:ready');
14 };
15
16
17=== modified file 'lib/lp/bugs/javascript/tests/test_bug_subscription_widget.js'
18--- lib/lp/bugs/javascript/tests/test_bug_subscription_widget.js 2010-12-14 10:42:45 +0000
19+++ lib/lp/bugs/javascript/tests/test_bug_subscription_widget.js 2011-01-06 13:22:30 +0000
20@@ -4,7 +4,7 @@
21 base: '../../../../canonical/launchpad/icing/yui/',
22 filter: 'raw',
23 combine: false,
24- fetchCSS: false
25+ fetchCSS: false,
26 }).use(
27 'event', 'event-simulate', 'lazr.testing.mockio',
28 'lp.bugs.bug_subscription_wizard', 'node', 'test',
29@@ -263,6 +263,30 @@
30 subscribe_form_body,
31 subscription_wizard.get('steps')[0].get('form_content'));
32 Assert.isTrue(subscription_wizard.get('visible'));
33+ },
34+
35+ test_submitting_wizard_form_fires_event: function() {
36+ // When the wizard form is submitted, a
37+ // subscriptionwizard:save event is fired.
38+ var subscriptionwizard_save_fired = false;
39+ Y.on(
40+ 'subscriptionwizard:save',
41+ Y.bind(function(e) { subscriptionwizard_save_fired = true; }));
42+ Y.on(
43+ 'subscriptionwizard:ready',
44+ Y.bind(function(e) {
45+ var subscription_wizard =
46+ Y.lp.bugs.bug_subscription_wizard.subscription_wizard;
47+ var submit_button =
48+ Y.one('input[type=submit]');
49+ Y.Event.simulate(Y.Node.getDOMNode(submit_button), 'click');
50+ }));
51+
52+ Y.lp.bugs.bug_subscription_wizard.initialize_subscription_wizard(
53+ subscribe_node, 'http://example.com', mock_io);
54+ mock_io.simulateXhr(success_response, false);
55+ Y.lp.bugs.bug_subscription_wizard.show_wizard();
56+ Assert.isTrue(subscriptionwizard_save_fired);
57 }
58 }));
59