Fix use of contains? in tax_rate.rb#657
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
This should probably be try!
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.
Contributor
|
👍 |
Contributor
|
I took the liberty of adding an additional spec :) |
Contributor
Author
|
Nice. Thank you! |
Merged
Contributor
|
I'm 👍 for this, I think we can slip it in for 1.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inTaxRate.This should ease mergeability of #650 (once this is in, #650 will really only be specs).