The comment about falling back to the default locale came from the first
commit, when the config was just `fallbacks = true`. The fallback logic
is a lot more sophisticated now and we can supply the country's default
locale as first fallback and our source locale `en` as last resort. It
should contain everything.
In the future, we may want to support maps like Canadian French can fall
back to original French. I18n supports this but providing the config per
isntance may be a bit tricky.
variant_tag feature check should happen per enterprise basis, but we
still want super admin to so see variant tag. To do so we check if the
user is amdin or if any of the current user enterprise has variant tag
enable.
I removed the caching of `managed_enterprises` in Permissions because
it's just a scope and calling it again is very cheap. And that makes the
method a lot easier to read now that we have a conditional here.
Accessing the managed enterprises via the user instead of a separate
scope on the Enterprise model also reduce the SQL queries. We may want
to use this method in more places. I prefer to keep the
admin-conditional in a permissions class instead of in the model.
Per review, the check is done on the same enterprise as the one use to
initialize ScopeVariantToHub. So it makes sense to move the actual
feature check to ScopeVariantToHub#scope
Currently inventory is enabled by default, but we enventually want to
disabled it by default. So we disable inventory for specs, it will be
enabled on specific specs to test inventory related code path.
This class was originally built to flexibly accept paramters in any order. It also allowed you to specify multiple of the same type of parameter, with the later one overriding the earlier.
This is too flexible and likely to cause mistakes. And besides, we don't use that feature!
We weren't bothering with stock when items were on demand anyway. But we
want to track stock now so that we can backorder more when local stock
levels become negative.