New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed method post_subscription() w.r.t checking ref of $subscription #68
Conversation
Well spotted @manwar! To make sure the code is now doing exactly what we expect and doesn't go missing through a clumsy merge, could you please write a unit test exploiting this fix? Thanks Andrew |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a unit test
Please review the proposed changes. Many Thanks. |
return $self->_post("customers/$customer/subscriptions/" . $subscription->id, $subscription); | ||
} elsif (defined($subscription) && !ref($subscription)) { | ||
return $self->_post("customers/$customer/subscriptions/" . $subscription, _defined_arguments(\%args)); | ||
if (defined($subscription)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 That's nice and clear!
@@ -201,7 +201,7 @@ Charges: { | |||
); | |||
} 'Created a charge object with metadata'; | |||
isa_ok $charge, 'Net::Stripe::Charge'; | |||
ok defined($charge->metadata), "charge has metadata"; | |||
ok defined($charge->metadata), "charge has metadata"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for white space clean-up, but in the future please do that as a separate commit so that reverting this change (in case of unexpected problems) won't collide with other code making logical changes in this area.
return $self->_post("customers/$customer/subscriptions/" . $subscription->id, $subscription); | ||
} | ||
else { | ||
die 'subscription should be of type Net::Stripe::Subscription'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tested! 👍
if (defined($subscription)) { | ||
if (ref($subscription)) { | ||
if (ref($subscription) eq 'Net::Stripe::Subscription') { | ||
return $self->_post("customers/$customer/subscriptions/" . $subscription->id, $subscription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't tested 👎
} | ||
} | ||
else { | ||
return $self->_post("customers/$customer/subscriptions/" . $subscription, _defined_arguments(\%args)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't tested 👎
subscription => $subs_list | ||
); | ||
}; | ||
ok $@, "subscription should be of type Net::Stripe::Subscription"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good test, but only of the failure case. Would it be possible to add tests for the two cases with the 👎 above?
Added two more test cases as requested. Many Thanks. |
Thanks @manwar but for some reason this test is failing when I apply your change to master
Would you be so kind as to create a pull request from a new fork of this repo? Many thanks, Andrew |
Hi Luke, please review the above change.
Many Thanks.
Best Regards,
Mohammad S Anwar