RailsEventStore / ecommerce

Application with CQRS and Event Sourcing built on Rails and Rails Event Store
MIT License
425 stars 72 forks source link

Better error when submitting order with out of stock product #390

Closed marlena-b closed 2 months ago

marlena-b commented 2 months ago

Issue: https://github.com/RailsEventStore/ecommerce/issues/375

Before when a product was added to an order and subsequently went out of stock before submission, the system incorrectly showed a success message "Your order is being submitted" while leaving the order in draft status. Now it shows "Order can not be submitted! Product not available in requested quantity!".

Zrzut ekranu 2024-09-1 o 22 05 50

There are a lot of changes. I will try to explain all of them in the comments below.

The implementation for the Result object was taken from this presentation: https://www.icloud.com/keynote/0x2bfAdGek3Eg-I_2kIomD-6g#Controller_refactoring (it lacks notes but you can check slides 7 and 17 for "before" and "after")

netlify[bot] commented 2 months ago

Deploy Preview for ecommerce-events failed.

Name Link
Latest commit 844d11048566c276b41dcd9d84372d778cdfbabf
Latest deploy log https://app.netlify.com/sites/ecommerce-events/deploys/66d4caad49c8960008bd4295
andrzejkrzywda commented 2 months ago

There are many changes in this pull request which I would like to debate separately, but as a whole I think it's ready to be merged.

  1. Let's change the Result pattern to exceptions - we already use exceptions here a lot and we could save one pattern
  2. Let's separate the service objects even if they are identical
  3. No need for inheritance in service objects
  4. process publishing events - let's have it for now, we will see how it feels in the code in the longer run, might be refactored later