Permalink
Browse files

Fixing behavior where an empty plan quantity field causes totals/pric…

…es to go to 0.

It should be interpreted as 1, not 0.
fixes #27
fixes #28
  • Loading branch information...
1 parent d5b3c42 commit 5037aa8447536a295a5044c10becc216612bb617 @Sturmanator Sturmanator committed Mar 2, 2012
Showing with 24 additions and 6 deletions.
  1. +10 −3 build/recurly.js
  2. +1 −1 build/recurly.min.js
  3. +4 −0 changelog.md
  4. +8 −1 src/js/ui.js
  5. +1 −1 version
View
@@ -1,4 +1,4 @@
-// Recurly.js - v2.0.4
+// Recurly.js - v2.0.5
//
// Communicates with Recurly <https://recurly.com> via a JSONP API,
// generates UI, handles user error, and passes control to the client
@@ -50,7 +50,7 @@ R.settings = {
, oneErrorPerField: true
};
-R.version = '2.0.4';
+R.version = '2.0.5';
R.dom = {};
@@ -1561,6 +1561,13 @@ function pullBillingInfoFields($form, billingInfo, options, pull) {
}
+function pullPlanQuantity($form, plan, options, pull) {
+ var qty = pull.field($form, '.plan .quantity', V(R.isValidQuantity));
+ // An empty quantity field indicates 1
+ plan.quantity = qty || 1;
+}
+
+
function verifyTOSChecked($form, pull) {
pull.field($form, '.accept_tos', V(R.isChecked));
}
@@ -2062,7 +2069,7 @@ R.buildSubscriptionForm = function(options) {
$form.find('.invalid').removeClass('invalid');
validationGroup(function(puller) {
- subscription.plan.quantity = puller.field($form, '.plan .quantity', V(R.isValidQuantity));
+ pullPlanQuantity($form, subscription.plan, options, puller);
pullAccountFields($form, account, options, puller);
pullBillingInfoFields($form, billingInfo, options, puller);
verifyTOSChecked($form, puller);
View
Oops, something went wrong.
View
@@ -1,5 +1,9 @@
#Recurly.js CHANGELOG
+##Version 2.0.5 (March 1, 2012)
+
+- Fixed issue where an empty plan quantity would cause totals to display as 0.
+
##Version 2.0.4 (February 9, 2012)
- Fix: Now fetches and sends currency code of a plan during new subscriptions.
View
@@ -507,6 +507,13 @@ function pullBillingInfoFields($form, billingInfo, options, pull) {
}
+function pullPlanQuantity($form, plan, options, pull) {
+ var qty = pull.field($form, '.plan .quantity', V(R.isValidQuantity));
+ // An empty quantity field indicates 1
+ plan.quantity = qty || 1;
+}
+
+
function verifyTOSChecked($form, pull) {
pull.field($form, '.accept_tos', V(R.isChecked));
}
@@ -1008,7 +1015,7 @@ R.buildSubscriptionForm = function(options) {
$form.find('.invalid').removeClass('invalid');
validationGroup(function(puller) {
- subscription.plan.quantity = puller.field($form, '.plan .quantity', V(R.isValidQuantity));
+ pullPlanQuantity($form, subscription.plan, options, puller);
pullAccountFields($form, account, options, puller);
pullBillingInfoFields($form, billingInfo, options, puller);
verifyTOSChecked($form, puller);
View
@@ -1 +1 @@
-2.0.4
+2.0.5

0 comments on commit 5037aa8

Please sign in to comment.