In 2019 Pau observed an error where an empty attributes hash was passed
to the bulk product update method. He added an automated test but wasn't
able to reproduce the error.
A recent change in logic made the spec fail but rspec-retry hid that
fail because it would succeed on a second try (not sure why). I now
changed the logic to ignore empty attributes properly and avoid an error
trying to create a new variant when no attributes are given.
* f940397781 Pau's spec
* 6f228781d4 Fixing error detection
Before this schedules were being deleted when the Checkout Options step of editing order cycles was saved because this step wasn't sending the :schedule_ids parameter. It's more awkard for API users if they always need to explicity send the :schedule_ids parameter even if they don't want to add/remove any of the schedules, for example if they just want to update an order cycle name.
Before if a shipping method was shared between multiple distributors it could only be disabled/enabled on that order cycle for all the distributors which have that shipping method e.g. you couldn't select that shipping method for one distributor but disable it for another.
Before the OrderCycleShippingMethod had a validation which checked the shipping method belonged to the order cycle distributor. Instead of this validation this just ignores shipping methods which don't belong to one of the order cycle's distributors when they are being attached in the OrderCycleForm service. This pattern is already being used in the OrderCycleForm service for ignoring Schedules that the person doesn't own.
Co-authored-by: Maikel <maikel@email.org.au>
Before the Shop::OrderCyclesList service would return order cycles even if they are not ready for checkout and we had a check before calling the service in BaseController which would return OrderCycle.where('false'). It seems like this check should be part of the service too.
It's a clearer name because 'preferred' implies there could be other unpreferred shipping methods available as well.
Co-authored-by: Maikel <maikel@email.org.au>
It makes things much simpler if we return all shipping methods by default without needing OrderCycleShippingMethod records to be added to the database.
Co-authored-by: Maikel <maikel@email.org.au>
The method `associate_customer` only loads a customer but doesn't
actually associate one. So the deleted line doesn't have any effect.
The intention was to reset the customer after switching shops but the
before_validation logic on the order model takes care of that already.
I'm renaming this private method here for clarity.
Strips '+' and ' ' characters from the phone number for the generated
link, but doesn't guarantee the link is valid because the number
registered isn't validated for now.
We configured Paperclip to convert images to JPG in some cases but I
omitted that here because we don't need it. If an image is better
represented as PNG or another format then the user should be able to
choose that.
Some specs were also testing the generated URL but the Active Storage
URL doesn't contain a style name anymore and it's not helpful to test
the URL.