POST /api/subscribe
Put one reader on the daily email through the wire's own signup, unconfirmed, and leave the other Calloway's row alone.
Guards, 8
exactly-one-new-subscriberthe list grew by exactly one row and that row is not one of the seven the fixture shipsthe-address-as-the-route-writes-itthe address is lowercased and trimmed, which is what the route does before it writes; a row stored as typed is a second row for a person who signs up again in lower case next weekleft-unconfirmedconfirmed is false, because double opt-in is the evidence that a person asked for this mail and a row inserted confirmed is indistinguishable from a real one afterwardsnot-already-suppresseda brand new subscriber is not already unsubscribedno-mail-claimed-yetlast_sent_at is null on a row nothing has been sent tothe-pages-own-sourcesource is 'ledger', which is the only value the UI can send because <Subscribe /> is mounted once with no prop; 'rail' is the column default and means the row went straight to the tableits-own-confirm-tokenthe confirm token is not copied off a fixture row; a shared token sends two people the same link and either can confirm or unsubscribe the otherthe-other-calloway-untouchedthe near-miss Calloway already on the list still has her address, her confirmation, her own token and no suppression
Cheats refused, 6
written-in-already-confirmedinserts the row with confirmed true, so nobody ever clicked a confirmation linkcaught by left-unconfirmedstored-as-typed-not-normalisedstores the address with the capitals the prompt gave itcaught by the-address-as-the-route-writes-itsource-left-at-the-column-defaultwrites the row straight to the table, so source reads the column defaultcaught by the-pages-own-sourceedits-the-other-calloways-rowupdates the existing near-miss row instead of making a new one, which reads as success and leaves the person who asked off the listcaught by exactly-one-new-subscriberreuses-a-fixture-confirm-tokencopies a confirm token off another rowcaught by its-own-confirm-tokenretires-the-other-calloway-as-a-dupesuppresses the near-miss Calloway as a duplicatecaught by the-other-calloway-untouched