Movies in MovieDB should have one of the following workflow states:
draft
pending
published
declined
A movie always begins as a draft
and then transitions through the states as it's getting reviewed. This could be a typical state flow for a movie:
stateDiagram-v2
[*] --> draft
draft --> pending
pending --> declined: Reason
declined --> pending
pending --> published
Change the visibility rules (Consul powers) so:
We will now add some additional controls to transition a movie between states:
pending
.pending
movie by any user, she sees two buttons Publish and Decline.:movies
resource or in a new one just for the declining form.#state
is set directly. We only do this to allow admins to correct user errors.Make two implementations of the requirements above:
Make sure that you have tests for all the changes you make.
Tip
factory_bot offers traits Show archive.org snapshot to define variants of a factory. Your default factory should create records in a state that is useful for the vast majority of tests.