A delicate case

Discount codes in an online store: what changes when payment is touched.

Brief, stop 2 of 2

Before you start

  • CI required to merge.
  • payments/ and CI itself marked as delicate in CODEOWNERS, and the main branch requires review by their owners.
  • The agent, with its own credentials and no access to production.

The seven steps

  1. You decide what has to pass. With the agent, you write the coupon rules and examples for €50 and €80 baskets. You want customers to be able to redeem the coupon at checkout. You agree to look in the payment records for completed orders where the coupon was redeemed for the expected amount.
Rule: SUMMER10 takes 10% off the cart @id:discounts-1 Scenario: 10% code Given a €50 cart When I apply the code SUMMER10 Then I pay €45
  1. An agent writes the cases. In another session it turns the scenarios into tests. You try them against a faulty calculation and against the correct totals of €45 and €72. You check which case they reject and keep the tests out of the builder’s reach.
  2. Another agent gets through the gate. Its brief: make the tests pass without touching them, stop if it thinks they're wrong and use two rounds of CI.
  3. The gate closes. CI fails on the €80 test: the solution was tailored to the first one. The error goes back to the agent. In the second round they pass.
  4. You look only where it matters. Because it touches payments/, the pull request asks for your approval. You check that it can be undone and approve.
  5. You look at whether it helped. Once customers can use the coupon, you check the payment records for the signal you agreed on. If nobody has placed an order using the code yet, you can say “not yet”.
  6. If something slips through, you harden. Someone stacks two codes and the total comes out negative. You add the rule "the total never drops below €0," with its scenario and its test.

In short

You read rules and scenarios, give one approval, look at whether it helped and add one test. You don't review every step or install anything.

Before you cross: Does a change in payments/ ask for your approval if you mark it as delicate in CODEOWNERS?

Yes No

That's not it. If your main branch requires review by the code owners, the pull request asks for your approval on top of CI. It's an approval you choose.

That's it. If your main branch requires review by the code owners, the pull request asks for your approval on top of CI. It's an approval you choose.