Skip to content
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

Bugfix: Ignore empty discount/addon arrays #109

Merged
merged 1 commit into from
Dec 8, 2015
Merged

Bugfix: Ignore empty discount/addon arrays #109

merged 1 commit into from
Dec 8, 2015

Conversation

clemens
Copy link

@clemens clemens commented Nov 19, 2015

The Braintree API is just fine with accepting an empty array – so FakeBraintree
should be fine with this as well.

Example:

Braintree::Subscription.update(subscription_id, discounts: {
  add: [],
  update: [{ existing_id: some_id, amount: some_amount }]
})

This previously failed because FakeBraintree would stop at the add key since
it can be found and isn't nil. After this patch, FakeBraintree continues on the
empty array and correctly updates the discount.

The Braintree API is just fine with accepting an empty array – so FakeBraintree
should be fine with this as well.

Example:

Braintree::Subscription.update(subscription_id, discounts: {
	add: [],
	update: [{ existing_id: some_id, amount: some_amount }]
})

This previously failed because FakeBraintree would stop at the `add` key since
it can be found and isn't nil. After this patch, FakeBraintree continues on the
empty array and correctly updates the discount.
@@ -152,6 +152,17 @@
expect(discounts.first.quantity).to eq 5
end

it 'updates an existing discount if an empty :add array is given' do
discount_id = 'abc123'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@clemens
Copy link
Author

clemens commented Dec 8, 2015

Any feedback on this?

@birarda
Copy link
Contributor

birarda commented Dec 8, 2015

Sorry @clemens been a bit behind on fake_braintree stuff. Merging!

birarda added a commit that referenced this pull request Dec 8, 2015
@birarda birarda merged commit 5f5aae1 into highfidelity:master Dec 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants