Rails has changed the way helpers are loaded. It's a bit weird. It was throwing lots of errors, and recommended using this setting, but now requires that all helpers are loaded explicitly. I'm not sure about this.
The mismatched use of hash attributes as strings and hash attributes as symbols here (attrs['name'] and attrs[:name]) meant that the conditional was not returning the expected results in the test.
This is a generic issue caused by a clash between state machines trying to define (or failing to define) the #open method on adjustments as part of their state changes interface. This method is already defined in Object. For more details, see: bb42e33bf7/lib/state_machines/machine.rb (L323-L350)
This used to happen via an after_save callback in Shipment, which called `order.update!`. That has recently been removed. After changing a shipment's selected shipping rate (shipping method), we need to ensure the order's totals and states are updated. We don't need to update all of the order's adjustments though (see previous commit).
FYI Spree handled this issue like this: 24388485ed, but there are lots of things about that commit that are clearly awful, like: params handling in a model, duplication of Order::Updater logic across the codebase, the Shipment class having responsiblity for knowing which things need to be updated on the order, etc. The result is ultimately the same as what we're doing here though.
Error is
```
Failure/Error: @app.call(env)
LoadError:
Unable to autoload constant Api::V0::OrderCyclesController, expected /Users/jibees/dev/openfoodnetwork/app/controllers/api/v0/order_cycles_controller.rb to define it
```
This will hopefully let us see in Bugsnag when #6038 happens and so
we'll have all the diagnostics data. The fact that the `order.distributor`
is optional but mandatory to create the customer already gives us some
clue.
- Once story has been created, still need to generate the story itself (in json file format). Help with command: `rake view_component_storybook:write_stories_json`
The previous permissions assumed that an adjustment's "adjustable" could only be only line items or orders, and that's no longer true. It's now commonly a shipment or a payment as well.
The simple order cycle factory was flexible enough already to work with
given suppliers and distributors. We are now re-using that code so that
you can pass these enterprises when creating a normal order cycle, too.