boomerdigital / solidus_flexi_variants

BSD 3-Clause "New" or "Revised" License
15 stars 31 forks source link

Add tests for customizations on frontend. Add optional scope to updat… #13

Open masonjeffreys opened 6 years ago

masonjeffreys commented 6 years ago

…ePrice function.

Although Solidus isn't set up out-of-the-box to allow multiple cart-forms on the same page, it is still good practice to make sure that the updatePrice function only interacts with the form fields on the correct product.

I added an optional context argument to the updatePrice function so that it will only update the price inside the context it is given (i.e. for the correct #cart-form).

I also added a test to illustrate the above context problem and several tests to exercise the calculators from the front end users perspective.

I also moved the partial lookup logic (first look in customization_type, then calculator_type, then fallback to a default) to a helper to clean up the view layer a bit.