Skip to content

Fix use of contains? in tax_rate.rb#657

Merged
cbrunsdon merged 3 commits intomasterfrom
unknown repository
Jan 11, 2016
Merged

Fix use of contains? in tax_rate.rb#657
cbrunsdon merged 3 commits intomasterfrom
unknown repository

Conversation

@mamhoff
Copy link
Copy Markdown
Contributor

@mamhoff mamhoff commented Jan 6, 2016

Previously, when checking a tax rate's applicability for an order, we would do two checks: Is it the same zone? If not: Does the tax rate's zone contain the other zone? Since a zone will always contain itself, I added an early return in Zone#contains? for that case, and unified the applicability checks in TaxRate.

This should ease mergeability of #650 (once this is in, #650 will really only be specs).

Consider I ask a zone whether it contains itself - that would be true, right?

`Zone#contains` is only ever called from `tax_rate.rb`, and every time it
gets called there is (or should be) a safeguard for this. Plus: It removes a
`create` call from the zone specs.
Comment thread core/app/models/spree/tax_rate.rb Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably be try!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, agree. Fixing.

@jhawthorn
Copy link
Copy Markdown
Contributor

Other than one comment this is good by me 👍

There's a bit of confusion around when a tax rate is applicable in the code.
Sometimes the order tax zone has to be equal the tax rates zone, and
sometimes it's ok if the tax rates' zone contains the order tax zone.

Using the shortcut from the previous commit, this can be unified.
@jhawthorn
Copy link
Copy Markdown
Contributor

👍

@jhawthorn
Copy link
Copy Markdown
Contributor

I took the liberty of adding an additional spec :)

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Jan 8, 2016

Nice. Thank you!

@mamhoff mamhoff mentioned this pull request Jan 8, 2016
@cbrunsdon
Copy link
Copy Markdown
Contributor

I'm 👍 for this, I think we can slip it in for 1.2

@cbrunsdon cbrunsdon merged commit 298f9a9 into solidusio:master Jan 11, 2016
@mamhoff mamhoff deleted the fix-use-of-contains-in-tax-rate branch January 17, 2016 17:12
@mamhoff mamhoff mentioned this pull request Mar 16, 2016
23 tasks
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